bigboard r7297 - trunk/bigboard/stocks/mail



Author: walters
Date: Mon Apr 14 23:02:36 2008
New Revision: 7297
URL: http://svn.gnome.org/viewvc/bigboard?rev=7297&view=rev

Log:
...except don't unescape XML entities.

Modified:
   trunk/bigboard/stocks/mail/MailStock.py

Modified: trunk/bigboard/stocks/mail/MailStock.py
==============================================================================
--- trunk/bigboard/stocks/mail/MailStock.py	(original)
+++ trunk/bigboard/stocks/mail/MailStock.py	Mon Apr 14 23:02:36 2008
@@ -32,6 +32,7 @@
 # @param text The HTML (or XML) source text.
 # @return The plain text, as a Unicode string, if necessary.
 def unescape_html_entities(text):
+    xml_entities = ["quot", "amp", "apos", "lt", "gt"]
     def fixup(m):
         text = m.group(0)
         if text[:2] == "&#":
@@ -45,8 +46,12 @@
                 pass
         else:
             # named entity
+            entityname = text[1:-1]
+            # Don't unescape valid XML entities
+            if entityname in xml_entities:
+                return text
             try:
-                text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
+                text = unichr(htmlentitydefs.name2codepoint[entityname])
             except KeyError:
                 pass
         return text # leave as is



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]