Skip to content

Commit d3201ee

Browse files
committed
Updated go.bug.st/relaxed-semver from 634f2c8 to 0265409
Fix #110
1 parent 1018e90 commit d3201ee

File tree

3 files changed

+52
-17
lines changed

3 files changed

+52
-17
lines changed

Diff for: Gopkg.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: vendor/go.bug.st/relaxed-semver/fuzzer.go

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Copyright 2018 Cristian Maglie. All rights reserved.
3+
// Use of this source code is governed by a BSD-style
4+
// license that can be found in the LICENSE file.
5+
//
6+
7+
// +build gofuzz
8+
9+
package semver
10+
11+
// Fuzz is used for fuzzy testing the project
12+
func Fuzz(data []byte) int {
13+
v, err := Parse(string(data))
14+
if err != nil {
15+
if v != nil {
16+
panic("v != nil on error")
17+
}
18+
return 0
19+
}
20+
if v.String() != string(data) {
21+
panic("reserialized string != deserialized string")
22+
}
23+
v.Normalize()
24+
if v.CompareTo(v) != 0 {
25+
panic("compare != 0 while comparing with self")
26+
}
27+
r := ParseRelaxed(string(data))
28+
if r.String() != string(data) {
29+
panic("reserialized relaxed string != deserialized string")
30+
}
31+
return 1
32+
}

Diff for: vendor/go.bug.st/relaxed-semver/parser.go

+18-15
Original file line numberDiff line numberDiff line change
@@ -222,23 +222,26 @@ func Parse(inVersioin string) (*Version, error) {
222222

223223
// Builds parsing
224224
buildIdx := currIdx + 1
225-
for {
226-
if hasNext := next(); !hasNext || curr == '.' {
227-
if buildIdx == currIdx {
228-
return nil, fmt.Errorf("empty build tag not allowed")
225+
if curr == '+' {
226+
for {
227+
if hasNext := next(); !hasNext || curr == '.' {
228+
if buildIdx == currIdx {
229+
return nil, fmt.Errorf("empty build tag not allowed")
230+
}
231+
result.builds = append(result.builds, in[buildIdx:currIdx])
232+
if !hasNext {
233+
return result, nil
234+
}
235+
236+
// Multiple builds
237+
buildIdx = currIdx + 1
238+
continue
229239
}
230-
result.builds = append(result.builds, in[buildIdx:currIdx])
231-
if !hasNext {
232-
return result, nil
240+
if identifier[curr] {
241+
continue
233242
}
234-
235-
// Multiple builds
236-
buildIdx = currIdx + 1
237-
continue
238-
}
239-
if identifier[curr] {
240-
continue
243+
return nil, fmt.Errorf("invalid separator for builds: '%c'", curr)
241244
}
242-
return nil, fmt.Errorf("invalid separator for builds: '%c'", curr)
243245
}
246+
return nil, fmt.Errorf("invalid separator: '%c'", curr)
244247
}

0 commit comments

Comments
 (0)