Skip to content

Commit f99f127

Browse files
authored
fix(version_compare): support + in versions (#3554)
Fixes #3552
1 parent 7202d21 commit f99f127

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

cve_bin_tool/version_compare.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def parse_version(version_string: str):
4444
# we could switch to a re split but it seems to leave blanks so this is less hassle
4545
versionString = versionString.replace("-", ".")
4646
versionString = versionString.replace("_", ".")
47+
versionString = versionString.replace("+", ".")
4748
# Note: there may be other non-alphanumeric characters we want to add here in the
4849
# future, but we'd like to look at those cases before adding them in case the version
4950
# logic is very different.

test/test_version_compare.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_lt(self):
3030
assert Version("rc5") < Version("rc10")
3131
assert Version("9.10") < Version("9.10.post")
3232
assert Version("5.3.9") < Version("5.4")
33+
assert Version("2.0.0") < Version("2.0.0-1+deb9u1")
3334

3435
def test_gt(self):
3536
"""Make sure > works between versions, including some with unusual version schemes"""
@@ -42,6 +43,7 @@ def test_gt(self):
4243
assert Version("10.2.3.rc10") > Version("10.2.3.rc2")
4344
assert Version("9.10.post") > Version("9.10")
4445
assert Version("5.5") > Version("5.4.1")
46+
assert Version("2.0.0-1+deb9u1") > Version("2.0.0")
4547

4648
def test_error(self):
4749
"""Make sure 'unknown' and blank strings raise appropriate errors"""

0 commit comments

Comments
 (0)