From 89da15892e107c17d576f43e4d9b4ebd88f12f92 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 8 Oct 2021 16:52:16 -0700 Subject: [PATCH 1/2] 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 ++- 1 file changed, 2 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", From 886217f7a757a81fc5be18cac876b2c8781926dd Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Mon, 11 Oct 2021 10:04:32 -0700 Subject: [PATCH 2/2] Add test for multi-line description --- tests/json/test_poetry_schema.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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