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

HH-210533 remove control characters from body in debug #697

Merged
merged 1 commit into from
Apr 11, 2024
Merged
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
7 changes: 4 additions & 3 deletions frontik/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def response_to_xml(result: RequestResult) -> etree.Element:
mode = 'html'
body = frontik.util.decode_string_from_charset(raw_body, try_charsets)
elif 'protobuf' in content_type:
body = repr(raw_body)
body = raw_body
elif 'xml' in content_type:
mode = 'xml'
body = _pretty_print_xml(etree.fromstring(raw_body))
Expand All @@ -77,11 +77,12 @@ def response_to_xml(result: RequestResult) -> etree.Element:

except Exception:
debug_log.exception('cannot parse response body')
body = repr(raw_body)
body = raw_body

try:
escaped_body = re.sub(r'\\n', '\n', repr(body)[1:-1])
response = E.response(
E.body(body, content_type=content_type, mode=mode),
E.body(escaped_body, content_type=content_type, mode=mode),
E.code(str(result.status_code)),
E.error(str(result.error)),
E.size(str(len(raw_body)) if raw_body is not None else '0'),
Expand Down
Loading