xmltodict icon indicating copy to clipboard operation
xmltodict copied to clipboard

Urlencoding is converted to charectrers

Open guysoft opened this issue 8 years ago • 3 comments

So trying to parse jenkins jobs, And it seesm url-encoded charecrters are converted to quotations.

Example:

import xmltodict
a = """<?xml version='1.0' encoding='UTF-8'?>
<command>echo &quot;Hello World&quot; </command>
"""
print(xmltodict.unparse(xmltodict.parse(a), None, 'UTF-8', True, True, pretty=True))

Expected output:

<?xml version="1.0" encoding="UTF-8"?>
<command>echo &quot;Hello World&quot;</command>

Actual output:

<?xml version="1.0" encoding="UTF-8"?>
<command>echo "Hello World"</command>

guysoft avatar Feb 27 '18 11:02 guysoft

Got a message that someone commmented and deleted:

Seems like it's a bug in sax python core library element.
We have two similar methods in python/Lib/xml/sax/saxutils.py: def escape() and def unescape(). I don't know why but there's no quotation escaping in escape() but unescape() has it.
I've tried to replace the return statement from return data to return data.replace("\"", "&quot;") and it worked great.

guysoft avatar Aug 21 '19 11:08 guysoft