Fallback to intense fixup of bad binary XML data
If the XML parser fails, attempt to replace binary data to try again. Change-Id: I659aec451b3ac596dc090c125939370bb251a62a
This commit is contained in:
parent
1a1e449965
commit
afac5284ab
@ -51,7 +51,16 @@ class Unsupported(Exception):
|
|||||||
def fromstring(inputdata):
|
def fromstring(inputdata):
|
||||||
if b'!entity' in inputdata.lower():
|
if b'!entity' in inputdata.lower():
|
||||||
raise Exception('Unsupported XML')
|
raise Exception('Unsupported XML')
|
||||||
return etree.fromstring(inputdata)
|
try:
|
||||||
|
return etree.fromstring(inputdata)
|
||||||
|
except etree.XMLSyntaxError:
|
||||||
|
inputdata = bytearray(inputdata.decode('utf8', errors='backslashreplace').encode())
|
||||||
|
for i in range(len(inputdata)):
|
||||||
|
if inputdata[i] < 0x20 and inputdata[i] not in (9, 0xa, 0xd):
|
||||||
|
inputdata[i] = 63
|
||||||
|
inputdata = bytes(inputdata)
|
||||||
|
return etree.fromstring(inputdata)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run_command_with_retry(connection, data):
|
def run_command_with_retry(connection, data):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user