Commit dcb1363a authored by Michael Ellis's avatar Michael Ellis Committed by Bryan C. Mills

cmd/go: parse dot-separated identifiers in build metadata

Per https://semver.org/#spec-item-10, build metadata may include
a series of dot separated identifiers.

Fixes #28647

Change-Id: I98655c62584a822953df71fba32b4a2cafe7a04b
Reviewed-on: https://go-review.googlesource.com/c/148835Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
parent 8bb3ae18
...@@ -263,7 +263,7 @@ func parseBuild(v string) (t, rest string, ok bool) { ...@@ -263,7 +263,7 @@ func parseBuild(v string) (t, rest string, ok bool) {
i := 1 i := 1
start := 1 start := 1
for i < len(v) { for i < len(v) {
if !isIdentChar(v[i]) { if !isIdentChar(v[i]) && v[i] != '.' {
return return
} }
if v[i] == '.' { if v[i] == '.' {
......
...@@ -44,6 +44,7 @@ var tests = []struct { ...@@ -44,6 +44,7 @@ var tests = []struct {
{"v1.2.3", "v1.2.3"}, {"v1.2.3", "v1.2.3"},
{"v1.2.3+meta", "v1.2.3"}, {"v1.2.3+meta", "v1.2.3"},
{"v1.2.3+meta-pre", "v1.2.3"}, {"v1.2.3+meta-pre", "v1.2.3"},
{"v1.2.3+meta-pre.sha.256a", "v1.2.3"},
} }
func TestIsValid(t *testing.T) { func TestIsValid(t *testing.T) {
......
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