Log message for revision 29927:
  
  - Collector #1750: StructuredText: fixed handling of image URLs
    with query string                                            i
  - some more unittests
  
  

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  2005-04-09 07:33:41 UTC (rev 29926)
+++ Zope/trunk/doc/CHANGES.txt  2005-04-09 08:52:18 UTC (rev 29927)
@@ -29,6 +29,9 @@
 
     Bugs fixed
   
+      - Collector #1750: StructuredText: fixed handling of image URLs
+        with query string
+
       - Collector #1748: Fixed SIGSEGV in Acquisition
 
       - Hotfix_20050405:  classes defined in untrusted code could shadow

Modified: Zope/trunk/lib/python/StructuredText/DocumentWithImages.py
===================================================================
--- Zope/trunk/lib/python/StructuredText/DocumentWithImages.py  2005-04-09 
07:33:41 UTC (rev 29926)
+++ Zope/trunk/lib/python/StructuredText/DocumentWithImages.py  2005-04-09 
08:52:18 UTC (rev 29927)
@@ -18,19 +18,19 @@
     "A simple embedded image"
 
 class DocumentWithImages(DocumentClass):
-    """
+    """ Document with images """
 
-    """
-
     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,
+        expr1=re.compile('\"([ 
_a-zA-Z0-9*.:/;,\-\n\~]+)\":img:([a-zA-Z0-9%\_\-.:/\?=;,\n\~]+)').search,
         ):
 
+
         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    
2005-04-09 07:33:41 UTC (rev 29926)
+++ Zope/trunk/lib/python/StructuredText/tests/testStructuredText.py    
2005-04-09 08:52:18 UTC (rev 29927)
@@ -138,7 +138,7 @@
 
         if not isinstance(stxtxt, UnicodeType):
             res = HTML(stxtxt,level=1,header=0)
-            if res.find(expected)==-1:
+            if not expected in res:
                 print "Text:     ",stxtxt
                 print "Converted:",res
                 print "Expected: ",expected
@@ -148,8 +148,10 @@
             ustxtxt = stxtxt
         else:
             ustxtxt = unicode(stxtxt)
+
         res = HTML(ustxtxt,level=1,header=0)
-        if res.find(expected)==-1:
+        if not expected in res:
+
             print "Text:     ",stxtxt.encode('latin-1')
             print "Converted:",res.encode('latin-1')
             print "Expected: ",expected.encode('latin-1')
@@ -210,13 +212,30 @@
         '<code>"literal":http://www.zope.org/.</code>')
 
 
+    def testLink(self):
+        self._test('"foo":http://www.zope.org/foo/bar',
+                   '<p><a href="http://www.zope.org/foo/bar";>foo</a></p>')
+
+        self._test('"foo":http://www.zope.org/foo/bar/%20x',
+                   '<p><a href="http://www.zope.org/foo/bar/%20x";>foo</a></p>')
+
+        self._test('"foo":http://www.zope.org/foo/bar?arg1=1&arg2=2',
+                   '<p><a 
href="http://www.zope.org/foo/bar?arg1=1&arg2=2";>foo</a></p>')
+     
     def testImgLink(self):
         self._test('"foo":img:http://www.zope.org/bar.gif',
-                   '<p><img src="http://www.zope.org/bar.gif"; alt="foo" />')
+                   '<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" 
/>')
+                   '<img src="http://www.zope.org:8080/bar.gif"; alt="foo">')
 
+        self._test('"foo":img:http://www.zope.org:8080/foo/bar?arg=1',
+                   '<img src="http://www.zope.org:8080/foo/bar?arg=1"; 
alt="foo">')
+
+        self._test('"foo":img:http://www.zope.org:8080/foo/b%20ar?arg=1',
+                   '<img src="http://www.zope.org:8080/foo/b%20ar?arg=1"; 
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.

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to