Commit db87c9f2 authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go: do not reject internal double-dots in path elements

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: default avatarJay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 55738850
......@@ -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")
}
......
......@@ -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")
}
......
......@@ -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},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment