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

Fail uploads with an invalid description #5835

Merged
merged 3 commits into from
May 12, 2019
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: 0 additions & 1 deletion tests/unit/forklift/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,6 @@ def test_fails_with_invalid_names(self, pyramid_config, db_request, name):
"for more information."
).format(name)

@pytest.mark.xfail(reason="https://github.com/pypa/warehouse/issues/4079")
@pytest.mark.parametrize(
("description_content_type", "description", "message"),
[
Expand Down
45 changes: 22 additions & 23 deletions warehouse/forklift/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,33 +934,32 @@ def file_upload(request):
rendered = None
if form.description.data:
description_content_type = form.description_content_type.data
# if not description_content_type:
# description_content_type = "text/x-rst"
if not description_content_type:
description_content_type = "text/x-rst"

rendered = readme.render(
form.description.data, description_content_type # use_fallback=False
form.description.data, description_content_type, use_fallback=False
)

# Uploading should prevent broken rendered descriptions.
# Temporarily disabled, see
# https://github.com/pypa/warehouse/issues/4079
# if rendered is None:
# if form.description_content_type.data:
# message = (
# "The description failed to render "
# "for '{description_content_type}'."
# ).format(description_content_type=description_content_type)
# else:
# message = (
# "The description failed to render "
# "in the default format of reStructuredText."
# )
# raise _exc_with_message(
# HTTPBadRequest,
# "{message} See {projecthelp} for more information.".format(
# message=message,
# projecthelp=request.help_url(_anchor="description-content-type"),
# ),
# ) from None
if rendered is None:
if form.description_content_type.data:
message = (
"The description failed to render "
"for '{description_content_type}'."
).format(description_content_type=description_content_type)
else:
message = (
"The description failed to render "
"in the default format of reStructuredText."
)
raise _exc_with_message(
HTTPBadRequest,
"{message} See {projecthelp} for more information.".format(
message=message,
projecthelp=request.help_url(_anchor="description-content-type"),
),
) from None

try:
canonical_version = packaging.utils.canonicalize_version(form.version.data)
Expand Down