module: reject "+" in CheckPath and CheckImportPath

"+" was allowed in some vcs regular expressions, but doesn't seem
to be used in practice anymore. Stop accepting it in import paths.
This is being submitted early in the Go 1.16 cycle so that if a
usage is detected it can be reverted. See the discussion in
golang.org/issue/31376 for more details.

For golang/go#31376

Change-Id: I392fcdcf829886bd0a28450ba5e399e64dd01559
Reviewed-on: https://go-review.googlesource.com/c/mod/+/250919
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/module/module.go b/module/module.go
index 3a8b080..77d6f8e 100644
--- a/module/module.go
+++ b/module/module.go
@@ -225,13 +225,13 @@
 }
 
 // pathOK reports whether r can appear in an import path element.
-// Paths can be ASCII letters, ASCII digits, and limited ASCII punctuation: + - . _ and ~.
+// Paths can be ASCII letters, ASCII digits, and limited ASCII punctuation: - . _ and ~.
 // This matches what "go get" has historically recognized in import paths.
 // 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 {
 	if r < utf8.RuneSelf {
-		return r == '+' || r == '-' || r == '.' || r == '_' || r == '~' ||
+		return r == '-' || r == '.' || r == '_' || r == '~' ||
 			'0' <= r && r <= '9' ||
 			'A' <= r && r <= 'Z' ||
 			'a' <= r && r <= 'z'
@@ -314,7 +314,7 @@
 // separated by slashes (U+002F). (It must not begin with nor end in a slash.)
 //
 // A valid path element is a non-empty string made up of
-// ASCII letters, ASCII digits, and limited ASCII punctuation: + - . _ and ~.
+// ASCII letters, ASCII digits, and limited ASCII punctuation: - . _ and ~.
 // It must not begin or end with a dot (U+002E), nor contain two dots in a row.
 //
 // The element prefix up to the first dot must not be a reserved file name
diff --git a/module/module_test.go b/module/module_test.go
index 1a6115f..8e56749 100644
--- a/module/module_test.go
+++ b/module/module_test.go
@@ -104,7 +104,7 @@
 	{"x.y(/z", false, false, true},
 	{"x.y)/z", false, false, true},
 	{"x.y*/z", false, false, false},
-	{"x.y+/z", false, true, true},
+	{"x.y+/z", false, false, true},
 	{"x.y,/z", false, false, true},
 	{"x.y-/z", true, true, true},
 	{"x.y./zt", false, false, false},
@@ -134,7 +134,7 @@
 	{"x.y/z(", false, false, true},
 	{"x.y/z)", false, false, true},
 	{"x.y/z*", false, false, false},
-	{"x.y/z+", true, true, true},
+	{"x.y/z+", false, false, true},
 	{"x.y/z,", false, false, true},
 	{"x.y/z-", true, true, true},
 	{"x.y/z.t", true, true, true},
@@ -241,7 +241,7 @@
 	path string
 	esc  string // empty means same as path
 }{
-	{path: "ascii.com/abcdefghijklmnopqrstuvwxyz.-+/~_0123456789"},
+	{path: "ascii.com/abcdefghijklmnopqrstuvwxyz.-/~_0123456789"},
 	{path: "github.com/GoogleCloudPlatform/omega", esc: "github.com/!google!cloud!platform/omega"},
 }