[Zope-Checkins] SVN: Zope/trunk/ - Collector #631: Image URLs in StructuredText containing port

Andreas Jung andreas at andreas-jung.com
Sun Nov 28 04:48:35 EST 2004


Log message for revision 28531:
        - Collector #631: Image URLs in StructuredText containing port
          numbers were not rendered correctly
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/StructuredText/DocumentWithImages.py
  U   Zope/trunk/lib/python/StructuredText/tests/testStructuredText.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2004-11-26 19:39:35 UTC (rev 28530)
+++ Zope/trunk/doc/CHANGES.txt	2004-11-28 09:48:35 UTC (rev 28531)
@@ -45,6 +45,9 @@
         text/<foo> types
 
     Bugs fixed
+        
+      - Collector #631: Image URLs in StructuredText containing port
+        numbers were not rendered correctly
 
       - Collector #1498: Don't choke on malformed cookies. Cookies of
         the form "foo=bar; hmm; baz=gee" will give an empty value for

Modified: Zope/trunk/lib/python/StructuredText/DocumentWithImages.py
===================================================================
--- Zope/trunk/lib/python/StructuredText/DocumentWithImages.py	2004-11-26 19:39:35 UTC (rev 28530)
+++ Zope/trunk/lib/python/StructuredText/DocumentWithImages.py	2004-11-28 09:48:35 UTC (rev 28531)
@@ -22,39 +22,15 @@
 
     """
 
-
     text_types = [
        'doc_img',
        ] + DocumentClass.text_types
 
-
     def doc_img(
         self, s,
         expr1=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+)').search,
-        expr2=re.compile('\"([ _a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9\_\-.:/;,\n\~]+):([a-zA-Z0-9_\-.:/;,\n\~]+)').search
         ):
 
-        r = expr2(s)
-        if r:
-
-            # Warning: the regex are getting confused when the string after :img:
-            # is an URL containing ":" (Collector #2276)
-            # Ugly workaround: check if have an absolute URL here. Not a cool solution,
-            # but it works !
-
-            if not r.group(2) in ['http','file','ftp']:
-
-                startt, endt = r.span(1)
-                startk, endk = r.span(2)
-                starth, endh = r.span(3)
-                start, end = r.span()
-
-                key = s[startk:endk]
-
-                return (StructuredTextImage(s[startt:endt], href=s[starth:endh], key=s[startk:endk]),
-                     start, end)
-
-
         r=expr1(s)
         if r:
             startt, endt = r.span(1)

Modified: Zope/trunk/lib/python/StructuredText/tests/testStructuredText.py
===================================================================
--- Zope/trunk/lib/python/StructuredText/tests/testStructuredText.py	2004-11-26 19:39:35 UTC (rev 28530)
+++ Zope/trunk/lib/python/StructuredText/tests/testStructuredText.py	2004-11-28 09:48:35 UTC (rev 28531)
@@ -210,6 +210,13 @@
         '<code>"literal":http://www.zope.org/.</code>')
 
 
+    def testImgLink(self):
+        self._test('"foo":img:http://www.zope.org/bar.gif',
+                   '<p><img src="http://www.zope.org/bar.gif" alt="foo" />')
+
+        self._test('"foo":img:http://www.zope.org:8080/bar.gif',
+                   '<p><img src="http://www.zope.org:8080/bar.gif" alt="foo" />')
+
     def XXXtestUnicodeContent(self):
         # This fails because ST uses the default locale to get "letters"
         # whereas it should use \w+ and re.U if the string is Unicode.



More information about the Zope-Checkins mailing list