diff options
author | Bryan C. Mills <bcmills@google.com> | 2021-03-09 17:23:04 -0500 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2021-03-10 03:08:37 +0000 |
commit | d33e2192a71c33a604af247161ba1d2c1969e4c7 (patch) | |
tree | 4b6aa7f18d629a2d697550a9af175b4a9a972f9a /src/cmd/vendor | |
parent | 41245ab28390fed22ba03ee87c0e3db97b16c73b (diff) | |
download | go-d33e2192a71c33a604af247161ba1d2c1969e4c7.tar.gz go-d33e2192a71c33a604af247161ba1d2c1969e4c7.zip |
cmd/go: allow '+' in package import paths in module mode
This change upgrades x/mod to pull in the fix from CL 300149.
Fixes #44776.
Change-Id: I273f41df2abfff76d91315b7f19fce851c8770d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/300176
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/vendor')
-rw-r--r-- | src/cmd/vendor/golang.org/x/mod/module/module.go | 38 | ||||
-rw-r--r-- | src/cmd/vendor/modules.txt | 2 |
2 files changed, 31 insertions, 9 deletions
diff --git a/src/cmd/vendor/golang.org/x/mod/module/module.go b/src/cmd/vendor/golang.org/x/mod/module/module.go index 272baeef17..0e03014837 100644 --- a/src/cmd/vendor/golang.org/x/mod/module/module.go +++ b/src/cmd/vendor/golang.org/x/mod/module/module.go @@ -224,12 +224,16 @@ func firstPathOK(r rune) bool { 'a' <= r && r <= 'z' } -// pathOK reports whether r can appear in an import path element. +// modPathOK reports whether r can appear in a module 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. +// +// This matches what "go get" has historically recognized in import paths, +// and avoids confusing sequences like '%20' or '+' that would change meaning +// if used in a URL. +// // TODO(rsc): We would like to allow Unicode letters, but that requires additional // care in the safe encoding (see "escaped paths" above). -func pathOK(r rune) bool { +func modPathOK(r rune) bool { if r < utf8.RuneSelf { return r == '-' || r == '.' || r == '_' || r == '~' || '0' <= r && r <= '9' || @@ -239,6 +243,17 @@ func pathOK(r rune) bool { return false } +// modPathOK reports whether r can appear in a package import path element. +// +// Import paths are intermediate between module paths and file paths: we allow +// disallow characters that would be confusing or ambiguous as arguments to +// 'go get' (such as '@' and ' ' ), but allow certain characters that are +// otherwise-unambiguous on the command line and historically used for some +// binary names (such as '++' as a suffix for compiler binaries and wrappers). +func importPathOK(r rune) bool { + return modPathOK(r) || r == '+' +} + // fileNameOK reports whether r can appear in a file name. // For now we allow all Unicode letters but otherwise limit to pathOK plus a few more punctuation characters. // If we expand the set of allowed characters here, we have to @@ -394,12 +409,19 @@ func checkElem(elem string, kind pathKind) error { if elem[len(elem)-1] == '.' { return fmt.Errorf("trailing dot in path element") } - charOK := pathOK - if kind == filePath { - charOK = fileNameOK - } for _, r := range elem { - if !charOK(r) { + ok := false + switch kind { + case modulePath: + ok = modPathOK(r) + case importPath: + ok = importPathOK(r) + case filePath: + ok = fileNameOK(r) + default: + panic(fmt.Sprintf("internal error: invalid kind %v", kind)) + } + if !ok { return fmt.Errorf("invalid char %q", r) } } diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt index b1a2c67581..b84ee5a7b1 100644 --- a/src/cmd/vendor/modules.txt +++ b/src/cmd/vendor/modules.txt @@ -28,7 +28,7 @@ golang.org/x/arch/x86/x86asm golang.org/x/crypto/ed25519 golang.org/x/crypto/ed25519/internal/edwards25519 golang.org/x/crypto/ssh/terminal -# golang.org/x/mod v0.4.2-0.20210301144719-c8bb1bd8a2aa +# golang.org/x/mod v0.4.2-0.20210309222212-d6ab96f2441f ## explicit golang.org/x/mod/internal/lazyregexp golang.org/x/mod/modfile |