Skip to content

Commit

Permalink
versionfmt/dpkg: remove leading digit requirement
Browse files Browse the repository at this point in the history
This is not strictly a requirement and affects some tracked Alpine Linux
packages.
  • Loading branch information
jzelinskie committed Feb 7, 2017
1 parent c8622d5 commit 1e9f14a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 0 additions & 4 deletions ext/versionfmt/dpkg/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ func newVersion(str string) (version, error) {
return version{}, errors.New("No version")
}

if !unicode.IsDigit(rune(v.version[0])) {
return version{}, errors.New("version does not start with digit")
}

for i := 0; i < len(v.version); i = i + 1 {
r := rune(v.version[i])
if !unicode.IsDigit(r) && !unicode.IsLetter(r) && !containsRune(versionAllowedSymbols, r) {
Expand Down
6 changes: 4 additions & 2 deletions ext/versionfmt/dpkg/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ func TestParse(t *testing.T) {
// Test invalid characters in epoch
{"a:0-0", version{}, true},
{"A:0-0", version{}, true},
// Test version not starting with a digit
{"0:abc3-0", version{}, true},
// Test version not starting with a digit.
// While recommended by the specification, this is not strictly required and
// at least one vulnerable Alpine package deviates from this scheme.
{"0:abc3-0", version{epoch: 0, version: "abc3", revision: "0"}, false},
}
for _, c := range cases {
v, err := newVersion(c.str)
Expand Down

0 comments on commit 1e9f14a

Please sign in to comment.