durusmail: quixote-users: Re: int/long inconsistency with htmltext
int/long inconsistency with htmltext
2003-11-16
Re: int/long inconsistency with htmltext
2003-11-16
Re: int/long inconsistency with htmltext
Greg Ward
2003-11-16
On 16 November 2003, To quixote-users@mems-exchange.org said:
> Neil, any clue why this is happening?  It's not immediately obvious from
> a quick glance at the code.

But if I upgrade that "quick glance" to a "brief examination", it is
pretty clear.  Here's a patch:

--- _py_htmltext.py.orig0       2003-11-11 11:32:21.000000000 -0500
+++ _py_htmltext.py     2003-11-16 16:21:06.000000000 -0500
@@ -170,9 +170,8 @@

 def _wraparg(klass, arg):
     if (classof(arg) is klass or
-        isinstance(arg, IntType) or
-        isinstance(arg, FloatType)):
-        # ints, floats, and htmltext are okay
+        isinstance(arg, (int, float, long))):
+        # ints, floats, longs, and htmltext are okay
         return arg
     else:
         # everything is gets wrapped


...assuming, of course, that requiring Python 2.2 is now acceptable.

(BTW, I don't see any harm in adding complex to the list of types that
get away without escaping: can the str() of a complex ever contain
anything other than digits and '()+j'?  And are those characters ever
"dangerous" in the HTML sense?)

        Greg
--
Greg Ward                          http://www.gerg.ca/
Clarke's Law:
Any sufficiently advanced technology is indistinguishable from magic.

reply