diff --git a/cve_bin_tool/version_compare.py b/cve_bin_tool/version_compare.py index 775abd1a72..962c96fe11 100644 --- a/cve_bin_tool/version_compare.py +++ b/cve_bin_tool/version_compare.py @@ -40,14 +40,11 @@ def parse_version(version_string: str): versionString = version_string.strip() versionArray = [] - # convert - and _ to be treated like . below + # convert all non alpha-numeric characters to be treated like . below # 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. + versionString = re.sub("[^0-9a-zA-Z]+", ".", versionString) + + # Note: This expression may need improvement if we need to handle unicode # Attempt a split split_version = versionString.split(".")