-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #4012 encoding of content-disposition parameters
Posting form data with field names containing "[]" were not recognized by other multipart/form-data parsers. The percent-encoding is only to be used on the filename parameter that follows how of a "file:" URI may be encoded according to RFC7578.
- Loading branch information
Showing
9 changed files
with
84 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Only encode content-disposition filename parameter using percent-encoding. | ||
Other parameters are encoded to quoted-string or RFC2231 extended parameter | ||
value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,18 +74,18 @@ def test_invalid_formdata_content_transfer_encoding() -> None: | |
|
||
async def test_formdata_field_name_is_quoted(buf, writer) -> None: | ||
form = FormData(charset="ascii") | ||
form.add_field("emails[]", "[email protected]", content_type="multipart/form-data") | ||
form.add_field("email 1", "[email protected]", content_type="multipart/form-data") | ||
payload = form() | ||
await payload.write(writer) | ||
assert b'name="emails%5B%5D"' in buf | ||
assert b'name="email\\ 1"' in buf | ||
|
||
|
||
async def test_formdata_field_name_is_not_quoted(buf, writer) -> None: | ||
form = FormData(quote_fields=False, charset="ascii") | ||
form.add_field("emails[]", "[email protected]", content_type="multipart/form-data") | ||
form.add_field("email 1", "[email protected]", content_type="multipart/form-data") | ||
payload = form() | ||
await payload.write(writer) | ||
assert b'name="emails[]"' in buf | ||
assert b'name="email 1"' in buf | ||
|
||
|
||
async def test_mark_formdata_as_processed() -> None: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters