[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/container/browser/ Contents/contents.pt didn't quote the values that were used in href:s, thus

Bjorn Tillenius bjoti777 at student.liu.se
Sun Dec 5 05:06:41 EST 2004


Log message for revision 28564:
  Contents/contents.pt didn't quote the values that were used in href:s, thus
  it couldn't function properly if the items contained certain characters.
  

Changed:
  U   Zope3/trunk/src/zope/app/container/browser/contents.pt
  U   Zope3/trunk/src/zope/app/container/browser/contents.py
  U   Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py

-=-
Modified: Zope3/trunk/src/zope/app/container/browser/contents.pt
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/contents.pt	2004-12-04 19:04:40 UTC (rev 28563)
+++ Zope3/trunk/src/zope/app/container/browser/contents.pt	2004-12-05 10:06:41 UTC (rev 28564)
@@ -52,7 +52,8 @@
 
         <metal:block tal:define="supportsRename view/supportsRename"
                      tal:repeat="item container_contents">
-          <tr tal:define="oddrow repeat/item/odd; url item/url"
+          <tr tal:define="oddrow repeat/item/odd; url item/url;
+                          id_quoted item/id/url:quote"
               tal:attributes="class python:oddrow and 'even' or 'odd'" >
             <td>
               <input type="checkbox" class="noborder" name="ids:list" id="#"
@@ -80,7 +81,7 @@
                      >foo</a
                   ><a href="#"
                      tal:attributes="href
-                         string:${request/URL}?rename_ids:list=${item/id}"
+                         string:${request/URL}?rename_ids:list=${id_quoted}"
                      tal:condition="supportsRename"
                      >&nbsp;&nbsp;</a
                 ></span
@@ -92,7 +93,7 @@
                      />
               <a href="#"
                  tal:attributes="href
-                                 string:${request/URL}?retitle_id=${item/id}"
+                                 string:${request/URL}?retitle_id=${id_quoted}"
                  tal:condition="item/retitleable"
                  tal:content="item/title|default"
                  >&nbsp;&nbsp;&nbsp;&nbsp;</a>

Modified: Zope3/trunk/src/zope/app/container/browser/contents.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/contents.py	2004-12-04 19:04:40 UTC (rev 28563)
+++ Zope3/trunk/src/zope/app/container/browser/contents.py	2004-12-05 10:06:41 UTC (rev 28564)
@@ -16,6 +16,8 @@
 $Id$
 """
 __docformat__ = 'restructuredtext'
+        
+import urllib
 
 from zope.app.traversing.interfaces import TraversalError
 from zope.security.interfaces import Unauthorized
@@ -148,7 +150,7 @@
         info['id'] = info['cb_id'] = id
         info['object'] = obj
 
-        info['url'] = id
+        info['url'] = urllib.quote(id.encode('utf-8'))
         info['rename'] = rename_ids.get(id)
         info['retitle'] = id == retitle_id
 

Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py	2004-12-04 19:04:40 UTC (rev 28563)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py	2004-12-05 10:06:41 UTC (rev 28564)
@@ -86,6 +86,18 @@
 
         self.failIf(filter(None, map(lambda x: x['icon'], info_list)))
 
+    def testInfoUnicode(self):
+        # If the id contains non-ASCII characters, url has to be quoted
+        container = self._TestView__newContext()
+        subcontainer = self._TestView__newContext()
+        container[u'f\xf6\xf6'] = subcontainer
+        
+        fc = self._TestView__newView(container)
+        info_list = fc.listContentInfo()
+
+        urls = map(lambda x: x['url'], info_list)
+        self.assert_('f%C3%B6%C3%B6' in urls)
+
     def testInfoWDublinCore(self):
         container = self._TestView__newContext()
         document = Document()



More information about the Zope3-Checkins mailing list