mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Check for invalid version with leading zeros
This commit is contained in:
@ -236,6 +236,12 @@ class ManifestSchema(BaseSchema):
|
||||
try:
|
||||
value = str(value)
|
||||
assert "." in value
|
||||
# check leading zeros
|
||||
try:
|
||||
semantic_version.Version(value)
|
||||
except ValueError as exc:
|
||||
if "Invalid leading zero" in str(exc):
|
||||
raise exc
|
||||
semantic_version.Version.coerce(value)
|
||||
except (AssertionError, ValueError):
|
||||
raise ValidationError(
|
||||
|
@ -859,6 +859,11 @@ def test_broken_schemas():
|
||||
ManifestValidationError, match=("Invalid semantic versioning format")
|
||||
):
|
||||
ManifestSchema().load_manifest(dict(name="MyPackage", version="broken_version"))
|
||||
# version with leading zeros
|
||||
with pytest.raises(
|
||||
ManifestValidationError, match=("Invalid semantic versioning format")
|
||||
):
|
||||
ManifestSchema().load_manifest(dict(name="MyPackage", version="01.02.00"))
|
||||
|
||||
# broken value for Nested
|
||||
with pytest.raises(ManifestValidationError, match=r"authors.*Invalid input type"):
|
||||
|
Reference in New Issue
Block a user