Skip to content

Commit

Permalink
Fail uploads with an invalid description (#5835)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed May 12, 2019
1 parent d08c2b5 commit 7a5befb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
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

0 comments on commit 7a5befb

Please sign in to comment.