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

Separate headers by CR LF #471

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion httpretty/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ def fill_filekind(self, fk):
)

for item in string_list:
fk.write(utf8(item) + b'\n')
fk.write(utf8(item) + b'\r\n')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, UTF-8 is not valid in headers:

Field values are usually constrained to the range of US-ASCII characters [USASCII]. Fields needing a greater range of characters can use an encoding, such as the one defined in [RFC8187].
https://www.rfc-editor.org/rfc/rfc9110.html#section-5.5-4

A recipient MUST parse an HTTP message as a sequence of octets in an encoding that is a superset of US-ASCII [USASCII]. Parsing an HTTP message as a stream of Unicode characters, without regard for the specific encoding, creates security vulnerabilities due to the varying ways that string processing libraries handle invalid multibyte character sequences that contain the octet LF (%x0A).
https://www.rfc-editor.org/rfc/rfc9112.html#section-2.2-2


fk.write(b'\r\n')

Expand Down