Skip to content

Commit 5994fa8

Browse files
authored
Require that package descriptions not include newlines (#219)
* 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
1 parent 2b4b8c4 commit 5994fa8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

poetry/core/json/schemas/poetry-schema.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
},
2020
"description": {
2121
"type": "string",
22-
"description": "Short package description."
22+
"description": "Short package description.",
23+
"pattern": "^[^\n]*$"
2324
},
2425
"keywords": {
2526
"type": "array",

tests/json/test_poetry_schema.py

+9
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,12 @@ def test_path_dependencies(base_object):
4242

4343
def test_multi_url_dependencies(multi_url_object):
4444
assert len(validate_object(multi_url_object, "poetry-schema")) == 0
45+
46+
47+
def test_multiline_description(base_object):
48+
bad_description = "Some multi-\nline string"
49+
base_object["description"] = bad_description
50+
51+
errors = validate_object(base_object, "poetry-schema")
52+
assert len(errors) == 1
53+
assert errors[0] == "[description] %r does not match '^[^\\n]*$'" % bad_description

0 commit comments

Comments
 (0)