forked from aio-libs/aiohttp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional flag for quoting fields
RFC stanard requires all fields to be US-ASCII. Additional `quote` may provide extra security (RFC-1806 p. 2.3), but does not allow for interoperability with API that requires ASCII characters outside `quote` set e.g. emails[] becomes emails%5B%5D fixes aio-libs#903
- Loading branch information
1 parent
f180199
commit b6061d4
Showing
3 changed files
with
21 additions
and
4 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
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 |
---|---|---|
|
@@ -131,6 +131,20 @@ def test_invalid_formdata_content_transfer_encoding(): | |
content_transfer_encoding=invalid_val) | ||
|
||
|
||
def test_formdata_field_name_is_quoted(): | ||
form = helpers.FormData() | ||
form.add_field("emails[]", "[email protected]", content_type="multipart/form-data") | ||
res = b"".join(form("ascii")) | ||
assert b'name="emails%5B%5D"' in res | ||
|
||
|
||
def test_formdata_field_name_is_not_quoted(): | ||
form = helpers.FormData(quote_fields=False) | ||
form.add_field("emails[]", "[email protected]", content_type="multipart/form-data") | ||
res = b"".join(form("ascii")) | ||
assert b'name="emails[]"' in res | ||
|
||
|
||
def test_access_logger_format(): | ||
log_format = '%T {%{SPAM}e} "%{ETag}o" %X {X} %%P' | ||
mock_logger = mock.Mock() | ||
|