versionfmt/dpkg: remove leading digit requirement

This is not strictly a requirement and affects some tracked Alpine Linux
packages.
This commit is contained in:
Jimmy Zelinskie 2017-02-07 11:51:10 -08:00
parent c8622d5f34
commit 1e9f14ae33
2 changed files with 4 additions and 6 deletions

View File

@ -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) {

View File

@ -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)