mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-100001: Also escape \s in http.server log messages. (GH-100038)
Also \ escape \s in the http.server BaseHTTPRequestHandler.log_message so
that it is technically possible to parse the line and reconstruct what the
original data was. Without this a \xHH is ambiguious as to if it is a hex
replacement we put in or the characters r"\x" came through in the original
request line.
(cherry picked from commit 7e29398407
)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
a726f747e6
commit
b2ff0f761d
3 changed files with 8 additions and 0 deletions
|
@ -566,6 +566,7 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
|
|||
# https://en.wikipedia.org/wiki/List_of_Unicode_characters#Control_codes
|
||||
_control_char_table = str.maketrans(
|
||||
{c: fr'\x{c:02x}' for c in itertools.chain(range(0x20), range(0x7f,0xa0))})
|
||||
_control_char_table[ord('\\')] = r'\\'
|
||||
|
||||
def log_message(self, format, *args):
|
||||
"""Log an arbitrary message.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue