"Joonas Liik" wrote in message
news:cab1gnptp0gd4s4kx07r1ujrnuxtoij4vf5unye1cfr_y0xv...@mail.gmail.com...
something like.. (untested)
def escape(untrusted_string):
''' Use on the user provided strings to render them inert for storage
escaping & ensures that the user cant type sth like '>' in
source and have it magically decode as '>'
'''
return untrusted_string.replace("&","&").replace("<",
"<").replace(">", ">")
def unescape(escaped_string):
'''Once the user string is retreived from storage use this
function to restore it to its original form'''
return escaped_string.replace("<","<").replace(">",
">").replace("&", "&")
i should note tho that this example is very ad-hoc, i'm no xml expert just
know a bit about xml entities. if you decide to go this route there are
probably some much better tested functions out there to escape text for
storage in xml documents.
Thanks very much, Joonas.
I understand now, and it seems to work fine.
As a bonus, I can now include '&' in my attributes in the future if the need
arises.
Much appreciated.
Frank
--
https://mail.python.org/mailman/listinfo/python-list