Skip to content

version_compare: support + in versions #3554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cve_bin_tool/version_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def parse_version(version_string: str):
# we could switch to a re split but it seems to leave blanks so this is less hassle
versionString = versionString.replace("-", ".")
versionString = versionString.replace("_", ".")
versionString = versionString.replace("+", ".")
# Note: there may be other non-alphanumeric characters we want to add here in the
# future, but we'd like to look at those cases before adding them in case the version
# logic is very different.
Expand Down
2 changes: 2 additions & 0 deletions test/test_version_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_lt(self):
assert Version("rc5") < Version("rc10")
assert Version("9.10") < Version("9.10.post")
assert Version("5.3.9") < Version("5.4")
assert Version("2.0.0") < Version("2.0.0-1+deb9u1")

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

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