Skip to content

Commit

Permalink
http_parser: use backslashreplace when reporting LineTooLong error
Browse files Browse the repository at this point in the history
This should avoid problems when the line contains characters that cannot
be decoded in the utf-8 encoding, which would generate a TypeError with
the xmlcharrefreplace encoding.
  • Loading branch information
ret2libc committed Oct 31, 2022
1 parent d6bbb2c commit d718a62
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions aiohttp/http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def parse_headers(
if len(bname) > self.max_field_size:
raise LineTooLong(
"request header name {}".format(
bname.decode("utf8", "xmlcharrefreplace")
bname.decode("utf8", "backslashreplace")
),
str(self.max_field_size),
str(len(bname)),
Expand All @@ -176,7 +176,7 @@ def parse_headers(
if header_length > self.max_field_size:
raise LineTooLong(
"request header field {}".format(
bname.decode("utf8", "xmlcharrefreplace")
bname.decode("utf8", "backslashreplace")
),
str(self.max_field_size),
str(header_length),
Expand All @@ -197,7 +197,7 @@ def parse_headers(
if header_length > self.max_field_size:
raise LineTooLong(
"request header field {}".format(
bname.decode("utf8", "xmlcharrefreplace")
bname.decode("utf8", "backslashreplace")
),
str(self.max_field_size),
str(header_length),
Expand Down

0 comments on commit d718a62

Please sign in to comment.