Skip to content

Commit 9a80067

Browse files
author
Bryan C. Mills
committed
[release-branch.go1.10-security] cmd/go/internal/get: relax pathOK check to allow any letter
This fixes a regression of #18660 with the new path checks. Change-Id: I07cd248392ba8f5f9b1614b79a323cca1ad1d46d Reviewed-on: https://team-review.git.corp.google.com/c/372708 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent aaa5f47 commit 9a80067

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ import (
1212
)
1313

1414
// The following functions are copied verbatim from cmd/go/internal/module/module.go,
15-
// with one change to additionally reject Windows short-names.
15+
// with a change to additionally reject Windows short-names,
16+
// and one to accept arbitrary letters (golang.org/issue/29101).
1617
//
1718
// TODO(bcmills): After the call site for this function is backported,
1819
// consolidate this back down to a single copy.
20+
//
21+
// NOTE: DO NOT MERGE THESE UNTIL WE DECIDE ABOUT ARBITRARY LETTERS IN MODULE MODE.
1922

2023
// CheckImportPath checks that an import path is valid.
2124
func CheckImportPath(path string) error {
@@ -120,18 +123,16 @@ func checkElem(elem string, fileName bool) error {
120123
}
121124

122125
// pathOK reports whether r can appear in an import path element.
123-
// Paths can be ASCII letters, ASCII digits, and limited ASCII punctuation: + - . _ and ~.
124-
// This matches what "go get" has historically recognized in import paths.
125-
// TODO(rsc): We would like to allow Unicode letters, but that requires additional
126-
// care in the safe encoding (see note below).
126+
//
127+
// NOTE: This function DIVERGES from module mode pathOK by accepting Unicode letters.
127128
func pathOK(r rune) bool {
128129
if r < utf8.RuneSelf {
129130
return r == '+' || r == '-' || r == '.' || r == '_' || r == '~' ||
130131
'0' <= r && r <= '9' ||
131132
'A' <= r && r <= 'Z' ||
132133
'a' <= r && r <= 'z'
133134
}
134-
return false
135+
return unicode.IsLetter(r)
135136
}
136137

137138
// fileNameOK reports whether r can appear in a file name.

0 commit comments

Comments
 (0)