[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ The '@' character is now allowed in object ids (RFC 1738 allows it).

Florent Guillaume fg at nuxeo.com
Tue Oct 4 07:02:53 EDT 2005


Log message for revision 38738:
  The '@' character is now allowed in object ids (RFC 1738 allows it).
  Expanded tests for _checkId.
  
  

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/lib/python/OFS/ObjectManager.py
  U   Zope/branches/Zope-2_8-branch/lib/python/OFS/tests/testObjectManager.py

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===================================================================
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt	2005-10-04 10:06:48 UTC (rev 38737)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt	2005-10-04 11:02:52 UTC (rev 38738)
@@ -29,6 +29,8 @@
       - Collector #1118: Added syntax to dtml-sqlgroup to support flexible
         generation of 'UPDATE' statements (bounty sponsored by Logicalware).
 
+      - The '@' character is now allowed in object ids (RFC 1738 allows it).
+
     Bugs Fixed
 
       - Collector #1863: Prevent possibly sensitive information to leak via

Modified: Zope/branches/Zope-2_8-branch/lib/python/OFS/ObjectManager.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/OFS/ObjectManager.py	2005-10-04 10:06:48 UTC (rev 38737)
+++ Zope/branches/Zope-2_8-branch/lib/python/OFS/ObjectManager.py	2005-10-04 11:02:52 UTC (rev 38738)
@@ -49,7 +49,7 @@
     XMLExportImport.magic: XMLExportImport.importXML,
     }
 
-bad_id=re.compile(r'[^a-zA-Z0-9-_~,.$\(\)# ]').search #TS
+bad_id=re.compile(r'[^a-zA-Z0-9-_~,.$\(\)# @]').search
 
 def checkValidId(self, id, allow_dup=0):
     # If allow_dup is false, an error will be raised if an object

Modified: Zope/branches/Zope-2_8-branch/lib/python/OFS/tests/testObjectManager.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/OFS/tests/testObjectManager.py	2005-10-04 10:06:48 UTC (rev 38737)
+++ Zope/branches/Zope-2_8-branch/lib/python/OFS/tests/testObjectManager.py	2005-10-04 11:02:52 UTC (rev 38738)
@@ -303,6 +303,41 @@
         om2._setObject(ob.getId(), ob)
         self.assertRaises(DeleteFailed, om1._delObject, 'om2')
 
+    def test_setObject_checkId_ok(self):
+        om = self._makeOne()
+        si = SimpleItem('1')
+        om._setObject('AB-dash_under0123', si)
+        si = SimpleItem('2')
+        om._setObject('ho.bak~', si)
+        si = SimpleItem('3')
+        om._setObject('dot.comma,dollar$(hi)hash# space', si)
+        si = SimpleItem('4')
+        om._setObject('b at r', si)
+        si = SimpleItem('5')
+        om._setObject('..haha', si)
+        si = SimpleItem('6')
+        om._setObject('.bashrc', si)
+
+    def test_setObject_checkId_bad(self):
+        from zExceptions import BadRequest
+        om = self._makeOne()
+        si = SimpleItem('111')
+        om._setObject('111', si)
+        si = SimpleItem('2')
+        self.assertRaises(BadRequest, om._setObject, 123, si)
+        self.assertRaises(BadRequest, om._setObject, 'a\x01b', si)
+        self.assertRaises(BadRequest, om._setObject, 'a\\b', si)
+        self.assertRaises(BadRequest, om._setObject, 'a:b', si)
+        self.assertRaises(BadRequest, om._setObject, 'a;b', si)
+        self.assertRaises(BadRequest, om._setObject, '.', si)
+        self.assertRaises(BadRequest, om._setObject, '..', si)
+        self.assertRaises(BadRequest, om._setObject, '_foo', si)
+        self.assertRaises(BadRequest, om._setObject, 'aq_me', si)
+        self.assertRaises(BadRequest, om._setObject, 'bah__', si)
+        self.assertRaises(BadRequest, om._setObject, '111', si)
+        self.assertRaises(BadRequest, om._setObject, 'REQUEST', si)
+        self.assertRaises(BadRequest, om._setObject, '/', si)
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest( unittest.makeSuite( ObjectManagerTests ) )



More information about the Zope-Checkins mailing list