Skip to content

Commit

Permalink
Require that package descriptions not include newlines (#219)
Browse files Browse the repository at this point in the history
* Require that package descriptions not include newlines

Previously, we would include the description-with-newlines directly as
the PKG-INFO summary, which could cause subtly broken builds (for
instance, the package may install, but none of the specified
dependencies).

Now, raise a validation error during building, like:

  RuntimeError

  The Poetry configuration is invalid:
    - [description] 'First line\nSecond line (BOOOOOM)' does not match '^[^\n]+$'

Closes python-poetry/poetry#1372
  • Loading branch information
tipabu authored Nov 10, 2021
1 parent 2b4b8c4 commit 5994fa8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion poetry/core/json/schemas/poetry-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
},
"description": {
"type": "string",
"description": "Short package description."
"description": "Short package description.",
"pattern": "^[^\n]*$"
},
"keywords": {
"type": "array",
Expand Down
9 changes: 9 additions & 0 deletions tests/json/test_poetry_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,12 @@ def test_path_dependencies(base_object):

def test_multi_url_dependencies(multi_url_object):
assert len(validate_object(multi_url_object, "poetry-schema")) == 0


def test_multiline_description(base_object):
bad_description = "Some multi-\nline string"
base_object["description"] = bad_description

errors = validate_object(base_object, "poetry-schema")
assert len(errors) == 1
assert errors[0] == "[description] %r does not match '^[^\\n]*$'" % bad_description

0 comments on commit 5994fa8

Please sign in to comment.