Merge "idegen: Handle symbolic link that targets to current or parent directory" am: d6c9ae2806 am: e78fac030c am: 517c07c85e am: 7db63833a3
Original change: https://android-review.googlesource.com/c/platform/development/+/2203929 Change-Id: I64d8affa689a137e448e41e313633a0491e7ad71 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -18,6 +18,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -153,6 +155,17 @@ public class Configuration {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Files.isSymbolicLink(file.toPath())) {
|
||||
Path target = Files.readSymbolicLink(file.toPath()).normalize();
|
||||
if (target.startsWith("") || target.startsWith(".")
|
||||
|| target.startsWith("..")) {
|
||||
// Don't recurse symbolic link that targets to parent
|
||||
// or current directory.
|
||||
Log.debug("Skipped: " + path);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (file.isDirectory()) {
|
||||
// Traverse nested directories.
|
||||
if (excludes.exclude(path)) {
|
||||
@@ -216,8 +229,7 @@ public class Configuration {
|
||||
* found.
|
||||
*/
|
||||
private static String parsePackageName(File file) throws IOException {
|
||||
BufferedReader in = new BufferedReader(new FileReader(file));
|
||||
try {
|
||||
try (BufferedReader in = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
String trimmed = line.trim();
|
||||
@@ -230,8 +242,6 @@ public class Configuration {
|
||||
}
|
||||
|
||||
return null;
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user