Skip to content

Commit eb241f9

Browse files
ewdurbindi
andauthored
limit length of response status line for _exc_with_message in forklift/legacy (#10508)
* limit length of response status line for _exc_with_message in forklift/legacy * Update warehouse/forklift/legacy.py Co-authored-by: Dustin Ingram <[email protected]> * fix test Co-authored-by: Dustin Ingram <[email protected]>
1 parent 439fd60 commit eb241f9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tests/unit/forklift/test_legacy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,11 @@ def test_fails_invalid_version(self, pyramid_config, pyramid_request, version):
943943
"md5_digest": "a fake md5 digest",
944944
"summary": "A" * 513,
945945
},
946-
"'" + "A" * 513 + "' is an invalid value for Summary. "
946+
"'"
947+
+ "A" * 30
948+
+ "..."
949+
+ "A" * 30
950+
+ "' is an invalid value for Summary. "
947951
"Error: Field cannot be longer than 512 characters. "
948952
"See "
949953
"https://packaging.python.org/specifications/core-metadata"

warehouse/forklift/legacy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,12 @@ def file_upload(request):
869869
if field.description and isinstance(field, wtforms.StringField):
870870
error_message = (
871871
"{value!r} is an invalid value for {field}. ".format(
872-
value=field.data, field=field.description
872+
value=(
873+
field.data[:30] + "..." + field.data[-30:]
874+
if len(field.data) > 60
875+
else field.data
876+
),
877+
field=field.description,
873878
)
874879
+ "Error: {} ".format(form.errors[field_name][0])
875880
+ "See "

0 commit comments

Comments
 (0)