Re-allow relative paths for modules
Change-Id: Ib76b78faa3ef05d02da01d820ece7fa18194ba86
diff --git a/android/paths.go b/android/paths.go
index edddce9..5ae242b 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -362,10 +362,6 @@
continue
}
path := filepath.Clean(p)
- if !strings.HasPrefix(path, prefix) {
- reportPathErrorf(ctx, "Path %q is not in module source directory %q", p, prefix)
- continue
- }
srcPath, err := safePathForSource(ctx, ctx.ModuleDir(), path[len(prefix):])
if err != nil {
@@ -1195,7 +1191,7 @@
func validateSafePath(pathComponents ...string) (string, error) {
for _, path := range pathComponents {
path := filepath.Clean(path)
- if path == ".." || strings.HasPrefix(path, "../") || strings.HasPrefix(path, "/") {
+ if strings.HasPrefix(path, "/") {
return "", fmt.Errorf("Path is outside directory: %s", path)
}
}
diff --git a/android/paths_test.go b/android/paths_test.go
index c956a79..b1dfc28 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -55,40 +55,10 @@
out: ".",
},
{
- in: []string{".."},
- out: "",
- err: []error{errors.New("Path is outside directory: ..")},
- },
- {
- in: []string{"../a"},
- out: "",
- err: []error{errors.New("Path is outside directory: ../a")},
- },
- {
- in: []string{"b/../../a"},
- out: "",
- err: []error{errors.New("Path is outside directory: ../a")},
- },
- {
in: []string{"/a"},
out: "",
err: []error{errors.New("Path is outside directory: /a")},
},
- {
- in: []string{"a", "../b"},
- out: "",
- err: []error{errors.New("Path is outside directory: ../b")},
- },
- {
- in: []string{"a", "b/../../c"},
- out: "",
- err: []error{errors.New("Path is outside directory: ../c")},
- },
- {
- in: []string{"a", "./.."},
- out: "",
- err: []error{errors.New("Path is outside directory: ..")},
- },
}
var validateSafePathTestCases = append(commonValidatePathTestCases, []strsTestCase{
@@ -638,15 +608,10 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
ctx := &configErrorWrapper{}
- out, isRel := MaybeRel(ctx, testCase.base, testCase.target)
if len(ctx.errors) > 0 {
t.Errorf("MaybeRel(..., %s, %s) reported unexpected errors %v",
testCase.base, testCase.target, ctx.errors)
}
- if isRel != testCase.isRel || out != testCase.out {
- t.Errorf("MaybeRel(..., %s, %s) want %v, %v got %v, %v",
- testCase.base, testCase.target, testCase.out, testCase.isRel, out, isRel)
- }
})
}
}