[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/ Merged bug fix from trunk.

Bjorn Tillenius bjoti777 at student.liu.se
Sun Dec 5 05:48:23 EST 2004


Log message for revision 28565:
  Merged bug fix from trunk.
  
  ------------------------------------------------------------------------
  r28564 | BjornT | 2004-12-05 12:06:41 +0200 (Sun, 05 Dec 2004) | 3 lines
  
  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/branches/ZopeX3-3.0/src/zope/app/container/browser/contents.pt
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/contents.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/tests/test_contents.py

-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/contents.pt
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/contents.pt	2004-12-05 10:06:41 UTC (rev 28564)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/contents.pt	2004-12-05 10:48:23 UTC (rev 28565)
@@ -50,7 +50,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="#"
@@ -78,7 +79,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
@@ -90,7 +91,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/branches/ZopeX3-3.0/src/zope/app/container/browser/contents.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/contents.py	2004-12-05 10:06:41 UTC (rev 28564)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/contents.py	2004-12-05 10:48:23 UTC (rev 28565)
@@ -16,6 +16,8 @@
 $Id$
 """
 __docformat__ = 'restructuredtext'
+        
+import urllib
 
 from zope.exceptions import NotFoundError
 from zope.security.interfaces import Unauthorized
@@ -147,7 +149,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/branches/ZopeX3-3.0/src/zope/app/container/browser/tests/test_contents.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/tests/test_contents.py	2004-12-05 10:06:41 UTC (rev 28564)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/container/browser/tests/test_contents.py	2004-12-05 10:48:23 UTC (rev 28565)
@@ -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