Commits

Mike Orr committed 1030207

Fix HTML overescaping in auto_link(). Patch by Marius Gedminas.

Comments (0)

Files changed (3)

 
 tip (development version)
 -------------------------
+* webhelpers.html.tools:
+  - Fix HTML overescaping in auto_link().  Patch by Marius Gedminas.
 * webhelpers.pylonslib:
   - Fix HTML overescaping.  Patch by Marius Gedminas.
 

tests/test_tools.py

         for k, v in result_values_templates.iteritems():
             result_values[k] = Template(v).substitute(raw_values)
 
+        self.assertEqual(result_values["email_result"], auto_link(raw_values['email_raw'], 'email_addresses'))
         self.assertEqual(u"hello %(email_result)s" % result_values, auto_link("hello %(email_raw)s" % raw_values, 'email_addresses'))
         self.assertEqual(u"Go to %(link_result)s" % result_values, auto_link("Go to %(link_raw)s" % raw_values, 'urls'))
         self.assertEqual(u"Go to %(link_raw)s" % raw_values, auto_link("Go to %(link_raw)s" % raw_values, 'email_addresses'))

webhelpers/html/tools.py

 
 def _auto_link_email_addresses(text):
     return lit_sub(r'([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)',
-                   r'<a href="mailto:\1">\1</a>', text)
+                   literal(r'<a href="mailto:\1">\1</a>'), text)
 
 def strip_links(text):
     """