[Erp5-report] r41868 kazuhiko - /erp5/trunk/products/PortalTransforms/transforms/safe_html.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Dec 29 22:44:53 CET 2010
Author: kazuhiko
Date: Wed Dec 29 22:44:53 2010
New Revision: 41868
URL: http://svn.erp5.org?rev=41868&view=rev
Log:
here, the output should be unicode not str. this part is only called in python-2.4, because python-2.6's HTMLParser.unescape() already decode such entities.
Modified:
erp5/trunk/products/PortalTransforms/transforms/safe_html.py
Modified: erp5/trunk/products/PortalTransforms/transforms/safe_html.py
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/transforms/safe_html.py?rev=41868&r1=41867&r2=41868&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/transforms/safe_html.py [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/transforms/safe_html.py [utf8] Wed Dec 29 22:44:53 2010
@@ -117,13 +117,12 @@ def decode_htmlentities(s):
def decode_htmlentity(m):
entity_value = m.groupdict()['htmlentity']
- if entity_value.lower().startswith('x'):
- try:
- return chr(int('0'+entity_value,16))
- except ValueError:
- return entity_value
try:
- return chr(int(entity_value))
+ if entity_value[0] in ['x','X']:
+ c = int(entity_value[1:], 16)
+ else:
+ c = int(entity_value)
+ return unichr(c)
except ValueError:
return entity_value
More information about the Erp5-report
mailing list