[Twisted-Python] minor patch to twisted.html.web
![](https://secure.gravatar.com/avatar/8ca35506ac08cebd833ab53032896c0b.jpg?s=120&d=mm&r=g)
When calling escape, this function seems to assume that the object being called is a string; although a user program could do this, an explict conversion here is more generous with the input arguments. --- html.py.orig Wed Feb 26 23:17:00 2003 +++ html.py Wed Feb 26 23:17:39 2003 @@ -36,6 +36,7 @@ def escape(text): "Escape a few HTML special chars with HTML entities." + text = str(text) for s, h in [('&', '&'), #order is important ('<', '<'), ('>', '>'),
![](https://secure.gravatar.com/avatar/b932b1e5a3e8299878e579f51f49b84a.jpg?s=120&d=mm&r=g)
On Wednesday, Feb 26, 2003, at 23:34 America/New_York, Clark C. Evans wrote:
When calling escape, this function seems to assume that the object being called is a string; although a user program could do this, an explict conversion here is more generous with the input arguments.
What about unicode? Ignoring the fact that unicode characters aren't escaped properly by this function (yet), if you str(text) you lose everything but 7bit ascii characters at best, and could very well raise an exception in the conversion to str. -bob
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday, February 26, 2003, at 10:33 PM, Bob Ippolito wrote:
What about unicode? Ignoring the fact that unicode characters aren't escaped properly by this function (yet), if you str(text) you lose everything but 7bit ascii characters at best, and could very well raise an exception in the conversion to str.
I agree. Thanks for the thought, Clark, but as traditional Python wisdom says, "In the face of ambiguity, refuse to guess." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (Darwin) iD8DBQE+XaySvVGR4uSOE2wRAkLLAKCsOsVkEZelKizeaLMcsIBOjxCJzgCeP2Gk ntlDPVaDocCwBC3Fd19kAR0= =8eHG -----END PGP SIGNATURE-----
participants (3)
-
Bob Ippolito
-
Clark C. Evans
-
Glyph Lefkowitz