fix(pypi): reject the line breaks in the env marker strings A line break outside of a string was already an error, but one inside of a quoted string was accepted. `packaging` rejects both and a marker is always on a single line of the metadata or of the requirements file, so a line break means that something went wrong when the marker was extracted.
diff --git a/news/pypi-env-marker-line-breaks.fixed.md b/news/pypi-env-marker-line-breaks.fixed.md new file mode 100644 index 0000000..9175951 --- /dev/null +++ b/news/pypi-env-marker-line-breaks.fixed.md
@@ -0,0 +1,2 @@ +(pypi) The environment markers that have a line break in a quoted string are +now rejected like the other invalid markers.
diff --git a/python/private/pypi/pep508_evaluate.bzl b/python/private/pypi/pep508_evaluate.bzl index ecf0ef6..c5451d2 100644 --- a/python/private/pypi/pep508_evaluate.bzl +++ b/python/private/pypi/pep508_evaluate.bzl
@@ -93,6 +93,9 @@ Returns: A tuple of the list of tokens and an error message, where one of them is None. """ + if "\n" in marker or "\r" in marker: + return None, "Unexpected line break" + tokens = [] rest = marker
diff --git a/tests/pypi/pep508/evaluate_tests.bzl b/tests/pypi/pep508/evaluate_tests.bzl index 745eed6..f737c63 100644 --- a/tests/pypi/pep508/evaluate_tests.bzl +++ b/tests/pypi/pep508/evaluate_tests.bzl
@@ -101,6 +101,9 @@ "os_name == 'posix' or or os_name == 'posix'", "os_name == 'posix' os_name == 'posix'", "os_name == 'posix'\n", + "os_name == 'po\nsix'", + "os_name == 'po\rsix'", + "os_name\r== 'posix'", "os_name == posix", "'posix' == 'posix'", "unknown_variable == 'posix'",