diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-12-05 14:47:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-05 14:47:57 -0800 |
commit | aae7b43ca3d2bb2028370b8252ccb51006827429 (patch) | |
tree | 355ac536a596ce3f4e6a46b03b1f86ea4b7e441d /Lib/http/server.py | |
parent | ec8c06bc28b29b62d31b953e54f1d8d8535faa80 (diff) | |
download | cpython-git-aae7b43ca3d2bb2028370b8252ccb51006827429.tar.gz |
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 7e29398407dbd53b714702abb89aa2fd7baca48a)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Diffstat (limited to 'Lib/http/server.py')
-rw-r--r-- | Lib/http/server.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index ca429428fd..03dbaa51b7 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -567,6 +567,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. |