Do not allow ":" and "/" chars in a package name

This commit is contained in:
Ivan Kravets
2020-06-22 15:25:02 +03:00
parent 87d5997b46
commit 967a856061
2 changed files with 11 additions and 1 deletions

View File

@ -149,7 +149,13 @@ class ExampleSchema(StrictSchema):
class ManifestSchema(BaseSchema):
# Required fields
name = fields.Str(required=True, validate=validate.Length(min=1, max=100))
name = fields.Str(
required=True,
validate=[
validate.Length(min=1, max=100),
validate.Regexp(r"^[^:/]+$", error="The next chars [:/] are not allowed"),
],
)
version = fields.Str(required=True, validate=validate.Length(min=1, max=50))
# Optional fields

View File

@ -841,3 +841,7 @@ def test_broken_schemas():
version="1.2.3",
)
)
# invalid package name
with pytest.raises(ManifestValidationError, match=("are not allowed")):
ManifestSchema().load_manifest(dict(name="C/C++ :library", version="1.2.3"))