From 5994fa8a339702927176b687d48acd12c14276a4 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 9 Nov 2021 22:03:53 -0800 Subject: [PATCH] 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 https://github.com/python-poetry/poetry/issues/1372 --- poetry/core/json/schemas/poetry-schema.json | 3 ++- tests/json/test_poetry_schema.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/poetry/core/json/schemas/poetry-schema.json b/poetry/core/json/schemas/poetry-schema.json index 708e000f8..519f7b9be 100644 --- a/poetry/core/json/schemas/poetry-schema.json +++ b/poetry/core/json/schemas/poetry-schema.json @@ -19,7 +19,8 @@ }, "description": { "type": "string", - "description": "Short package description." + "description": "Short package description.", + "pattern": "^[^\n]*$" }, "keywords": { "type": "array", diff --git a/tests/json/test_poetry_schema.py b/tests/json/test_poetry_schema.py index 905427eb1..e414f7f9d 100644 --- a/tests/json/test_poetry_schema.py +++ b/tests/json/test_poetry_schema.py @@ -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