]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: do not reject internal double-dots in path elements
authorBryan C. Mills <bcmills@google.com>
Fri, 27 Sep 2019 17:03:07 +0000 (13:03 -0400)
committerBryan C. Mills <bcmills@google.com>
Fri, 27 Sep 2019 17:28:24 +0000 (17:28 +0000)
The relative path element ".." is already rejected
by the checks for leading and trailing dots.

Fixes #27299

Change-Id: Ia8ab543c93288cdc0615abd6d22521d44bc56d72
Reviewed-on: https://go-review.googlesource.com/c/go/+/197720
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/internal/get/path.go
src/cmd/go/internal/module/module.go
src/cmd/go/internal/module/module_test.go

index 67d7b8a47c2957e8745e38ed6e123f88a32e3584..95169fa5f184ee55519912169b072b90def94b48 100644 (file)
@@ -44,9 +44,6 @@ func checkPath(path string, fileName bool) error {
        if path[0] == '-' {
                return fmt.Errorf("leading dash")
        }
-       if strings.Contains(path, "..") {
-               return fmt.Errorf("double dot")
-       }
        if strings.Contains(path, "//") {
                return fmt.Errorf("double slash")
        }
index 3d1ad2762875b3c03496ff113c700d676f662db4..3b70574e23ef61192ceef0ab6af499e6f4ae2e63 100644 (file)
@@ -231,9 +231,6 @@ func checkPath(path string, fileName bool) error {
        if path[0] == '-' {
                return fmt.Errorf("leading dash")
        }
-       if strings.Contains(path, "..") {
-               return fmt.Errorf("double dot")
-       }
        if strings.Contains(path, "//") {
                return fmt.Errorf("double slash")
        }
index b9f07bf57d549c6509d29d601c7f8d2fb33a41f6..2c22ee793908fae27eaaaf53e563eae709619d7a 100644 (file)
@@ -80,7 +80,7 @@ var checkPathTests = []struct {
        {"x./z", false, false, false},
        {".x/z", false, false, true},
        {"-x/z", false, false, false},
-       {"x..y/z", false, false, false},
+       {"x..y/z", true, true, true},
        {"x.y/z/../../w", false, false, false},
        {"x.y//z", false, false, false},
        {"x.y/z//w", false, false, false},
@@ -173,6 +173,7 @@ var checkPathTests = []struct {
        // When we do, we'll enable them everywhere, not just for GitHub.
        {"github.com/user/unicode/испытание", false, false, true},
 
+       {".../x", false, false, false},
        {"../x", false, false, false},
        {"./y", false, false, false},
        {"x:y", false, false, false},