Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description cannot contain a newline. #2470

Merged
merged 1 commit into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1390.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Newlines in metadata description/Summary now trigger a ValueError.
9 changes: 8 additions & 1 deletion setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ def _read_list(name):
self.obsoletes = None


def single_line(val):
# quick and dirty validation for description pypa/setuptools#1390
if '\n' in val:
raise ValueError("newlines not allowed")
return val


# Based on Python 3.5 version
def write_pkg_file(self, file): # noqa: C901 # is too complex (14) # FIXME
"""Write the PKG-INFO format data to a file object.
Expand All @@ -130,7 +137,7 @@ def write_field(key, value):
write_field('Metadata-Version', str(version))
write_field('Name', self.get_name())
write_field('Version', self.get_version())
write_field('Summary', self.get_description())
write_field('Summary', single_line(self.get_description()))
write_field('Home-page', self.get_url())

if version < StrictVersion('1.2'):
Expand Down