Author: pekka.klarck
Date: Wed Apr 29 03:30:16 2009
New Revision: 1992

Modified:
   trunk/src/robot/utils/htmlutils.py
   trunk/utest/utils/test_htmlutils.py

Log:
Escape " in URLs with " (issue 313)

Modified: trunk/src/robot/utils/htmlutils.py
==============================================================================
--- trunk/src/robot/utils/htmlutils.py  (original)
+++ trunk/src/robot/utils/htmlutils.py  Wed Apr 29 03:30:16 2009
@@ -146,7 +146,7 @@

 def _repl_url(res, formatting):
     pre = res.group(1)
-    url = res.group(3)
+    url = res.group(3).replace('"', '"')
     if formatting and os.path.splitext(url)[1].lower() \
            in ['.jpg', '.jpeg', '.png', '.gif', '.bmp']:
return '%s<img src="%s" title="%s" style="border: 1px solid gray" />' % (pre, url, url)

Modified: trunk/utest/utils/test_htmlutils.py
==============================================================================
--- trunk/utest/utils/test_htmlutils.py (original)
+++ trunk/utest/utils/test_htmlutils.py Wed Apr 29 03:30:16 2009
@@ -43,10 +43,13 @@
                 assert_equals(html_escape(inp), exp)
                 assert_equals(html_escape(inp, True), exp)
         assert_equals(html_escape('"<&>"'), '"&lt;&amp;&gt;"')
+

+class TestLinks(unittest.TestCase):
+
     def test_not_links(self):
- for nolink in [ 'http no link', 'http:/no', 'xx://no', 'tooolong10://no',
-                        'http://', 'http:// no' ]:
+        for nolink in ['http no link', 'http:/no', 'xx://no',
+                       'tooolong10://no', 'http://', 'http:// no']:
             assert_equals(html_escape(nolink, True), nolink)
             assert_equals(html_escape(nolink, False), nolink)

@@ -95,6 +98,10 @@
             assert_equals(html_escape(inp, False), link % (url, url))
assert_equals(html_escape(inp.upper(), True), img % (uprl, uprl)) assert_equals(html_escape(inp.upper(), False), link % (uprl, uprl))
+
+    def test_link_with_quot(self):
+        assert_equals(html_escape('http://foo"bar'),
+ '<a href="http://foo&quot;bar";>http://foo&quot;bar</a>')


 class TestHtmlEscapeWithFormatting(unittest.TestCase):

Reply via email to