mirror of https://github.com/golang/go.git
[release-branch.go1.11-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: I2dd9adab999e7f810e0e746ad8b75ea9622f56e7 Reviewed-on: https://team-review.git.corp.google.com/c/372706 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
d01ccd8ee8
commit
d39cd4d6d7
|
|
@ -12,10 +12,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// The following functions are copied verbatim from cmd/go/internal/module/module.go,
|
// The following functions are copied verbatim from cmd/go/internal/module/module.go,
|
||||||
// with one change to additionally reject Windows short-names.
|
// with a change to additionally reject Windows short-names,
|
||||||
|
// and one to accept arbitrary letters (golang.org/issue/29101).
|
||||||
//
|
//
|
||||||
// TODO(bcmills): After the call site for this function is backported,
|
// TODO(bcmills): After the call site for this function is backported,
|
||||||
// consolidate this back down to a single copy.
|
// consolidate this back down to a single copy.
|
||||||
|
//
|
||||||
|
// NOTE: DO NOT MERGE THESE UNTIL WE DECIDE ABOUT ARBITRARY LETTERS IN MODULE MODE.
|
||||||
|
|
||||||
// CheckImportPath checks that an import path is valid.
|
// CheckImportPath checks that an import path is valid.
|
||||||
func CheckImportPath(path string) error {
|
func CheckImportPath(path string) error {
|
||||||
|
|
@ -120,10 +123,8 @@ func checkElem(elem string, fileName bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// pathOK reports whether r can appear in an import path element.
|
// pathOK reports whether r can appear in an import path element.
|
||||||
// Paths can be ASCII letters, ASCII digits, and limited ASCII punctuation: + - . _ and ~.
|
//
|
||||||
// This matches what "go get" has historically recognized in import paths.
|
// NOTE: This function DIVERGES from module mode pathOK by accepting Unicode letters.
|
||||||
// TODO(rsc): We would like to allow Unicode letters, but that requires additional
|
|
||||||
// care in the safe encoding (see note below).
|
|
||||||
func pathOK(r rune) bool {
|
func pathOK(r rune) bool {
|
||||||
if r < utf8.RuneSelf {
|
if r < utf8.RuneSelf {
|
||||||
return r == '+' || r == '-' || r == '.' || r == '_' || r == '~' ||
|
return r == '+' || r == '-' || r == '.' || r == '_' || r == '~' ||
|
||||||
|
|
@ -131,7 +132,7 @@ func pathOK(r rune) bool {
|
||||||
'A' <= r && r <= 'Z' ||
|
'A' <= r && r <= 'Z' ||
|
||||||
'a' <= r && r <= 'z'
|
'a' <= r && r <= 'z'
|
||||||
}
|
}
|
||||||
return false
|
return unicode.IsLetter(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fileNameOK reports whether r can appear in a file name.
|
// fileNameOK reports whether r can appear in a file name.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
[!exec:git] skip
|
||||||
|
|
||||||
|
cd $WORK/_origin/example.com/unicode
|
||||||
|
exec git init
|
||||||
|
exec git add unicode.go
|
||||||
|
exec git commit -m 'add unicode.go'
|
||||||
|
|
||||||
|
mkdir $GOPATH/src/example.com/unicode
|
||||||
|
cd $GOPATH/src/example.com/unicode
|
||||||
|
exec git clone $WORK/_origin/example.com/unicode .
|
||||||
|
|
||||||
|
cd $WORK/_origin/example.com/испытание
|
||||||
|
exec git init
|
||||||
|
exec git add испытание.go
|
||||||
|
exec git commit -m 'add испытание.go'
|
||||||
|
|
||||||
|
mkdir $GOPATH/src/example.com/испытание
|
||||||
|
cd $GOPATH/src/example.com/испытание
|
||||||
|
exec git clone $WORK/_origin/example.com/испытание .
|
||||||
|
|
||||||
|
cd $GOPATH
|
||||||
|
go get -u example.com/unicode
|
||||||
|
|
||||||
|
-- $WORK/_origin/example.com/unicode/unicode.go --
|
||||||
|
package unicode
|
||||||
|
import _ "example.com/испытание"
|
||||||
|
-- $WORK/_origin/example.com/испытание/испытание.go --
|
||||||
|
package испытание
|
||||||
Loading…
Reference in New Issue