mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-13 07:56:14 +01:00
Merge pull request #1291 from andreas-schwab/master
Decode entities in HTTPError message body
This commit is contained in:
commit
8b5f0139e1
@ -168,6 +168,19 @@ def xml_escape(string):
|
||||
return xml.sax.saxutils.escape(string, entities=entities)
|
||||
|
||||
|
||||
def xml_unescape(string):
|
||||
"""
|
||||
Decode XML entities in the string.
|
||||
"""
|
||||
entities = {
|
||||
""": "\"",
|
||||
"'": "'",
|
||||
}
|
||||
if isinstance(string, bytes):
|
||||
return xml.sax.saxutils.unescape(string.decode("utf-8"), entities=entities).encode("utf-8")
|
||||
return xml.sax.saxutils.unescape(string, entities=entities)
|
||||
|
||||
|
||||
def xml_indent(root):
|
||||
"""
|
||||
Indent XML so it looks pretty after printing or saving to file.
|
||||
|
@ -115,7 +115,7 @@ def run(prg, argv=None):
|
||||
if b'<summary>' in body:
|
||||
msg = body.split(b'<summary>')[1]
|
||||
msg = msg.split(b'</summary>')[0]
|
||||
msg = _private.api.xml_escape(msg)
|
||||
msg = _private.api.xml_unescape(msg)
|
||||
print(decode_it(msg), file=sys.stderr)
|
||||
if e.code >= 500 and e.code <= 599:
|
||||
print(f'\nRequest: {e.filename}')
|
||||
|
Loading…
Reference in New Issue
Block a user