Skip to content

Commit 1e410c0

Browse files
authored
fix: edge case with packagist versioning (#4717)
Caught this failure on the coarse version fuzzing test. Packagist versions collapse repeated separators into one.
1 parent 9a670da commit 1e410c0

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

osv/ecosystems/coarse_version_monotonicity_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def test_nuget(self, v1_str, v2_str):
143143
check_coarse_version_monotonic(self, nuget.NuGet(), v1_str, v2_str)
144144

145145
@given(packagist_version_strategy, packagist_version_strategy)
146+
@example('0__1', '00')
146147
def test_packagist(self, v1_str, v2_str):
147148
check_coarse_version_monotonic(self, packagist.Packagist(), v1_str, v2_str)
148149

osv/ecosystems/packagist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def php_canonicalize_version(version: str) -> str:
147147
"""
148148
if version.startswith('v'):
149149
version = version[1:]
150-
replaced = re.sub('[-_+]', '.', version)
150+
replaced = re.sub('[-_+.]+', '.', version)
151151
replaced = re.sub(r'([^\d.])(\d)', r'\1.\2', replaced)
152152
replaced = re.sub(r'(\d)([^\d.])', r'\1.\2', replaced)
153153
return replaced

0 commit comments

Comments
 (0)