xml escapedness

Tim van der Leeuw tnleeuw at gmail.com
Sat Feb 23 03:54:34 EST 2008


On Fri, Feb 22, 2008 at 6:41 PM, Robin Becker <robin at reportlab.com> wrote:

> Tim van der Leeuw wrote:
> > On Fri, Feb 22, 2008 at 5:17 PM, Robin Becker <robin at reportlab.com>
> wrote:
> >
> [...]
> >
> > Well -- you escape them in the save() method only when they contain XML
> > charachters like <, > ? How about that, wouldn't that work?
> >
> > --Tim
> >
> ......
> That might work, but there are all the ampersands etc etc to consider as
> well.
> So an escaped string could contain &, but so can a raw string.
> --
> Robin Becker
>

The way I see it, is that escaped XML is sure to contain ampersands, but
'real' XML is sure to contain < > brackets. If it doesn't contain any
angle-brackets, then what's XML about it - it contains no tags? ;-)

So I guess that looking for < or > will work as a heuristic, in 99.9999% of
the cases - if not more ;-)

Oh, and yes I agree with the other posters that it would be better to store
it unescaped, and escape it where you need it.

Cheers,

--Tim



>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080223/a5bc77c0/attachment-0001.html>


More information about the Python-list mailing list