[issue39011] ElementTree attributes replace "\r" with "\n"

mefistotelis report at bugs.python.org
Sun Feb 9 19:24:28 EST 2020


mefistotelis <mefistotelis at gmail.com> added the comment:

Patch attached.

I was thinking about one for() instead, but didn't wanted to introduce too large changes..

Let me know if you would prefer something like:

    for i in (9,10,13,):
        if chr(i) not in text: continue
        text = text.replace(chr(i), "&#{:02d};".format(i))

That would also make it easy to extend for other chars, ie. if we'd like  the parser to be always able to re-read the XML we've created. Currently, placing control chars in attributes will prevent that. But I'm getting out of scope of this issue now.

----------
keywords: +patch
Added file: https://bugs.python.org/file48885/0001-bpo-39011-Preserve-line-endings-within-attributes.patch

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39011>
_______________________________________


More information about the Python-bugs-list mailing list