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