Closed GoogleCodeExporter closed 9 years ago
Original comment by nekoh...@gmail.com
on 6 Jan 2008 at 2:02
I think this could be fixed with this function but i didn't test it yet:
def escape(cls, text, quotes=True):
"""Create a Markup instance from a string and escape special characters
it may contain (<, >, & and ").
If the `quotes` parameter is set to `False`, the " character is left as
is. Escaping quotes is generally only required for strings that are to
be used in attribute values.
"""
if isinstance(text, cls):
return text
if not text:
return cls()
text = str(text).replace('&', '&') \
.replace('<', '<') \
.replace('>', '>')
if quotes:
text = text.replace('"', '"')
return cls(text)
escape = classmethod(escape)
Original comment by woutclym...@gmail.com
on 11 Mar 2008 at 10:52
Original comment by nekoh...@gmail.com
on 20 Mar 2009 at 11:27
Original comment by nekoh...@gmail.com
on 16 Apr 2011 at 3:29
Original issue reported on code.google.com by
nekoh...@gmail.com
on 6 Jan 2008 at 2:01Attachments: