[Checkins] SVN: zope.schema/trunk/ Don't allow "[\]^`" in DottedName.
Brian Sutherland
jinty at web.de
Sun Dec 19 08:00:57 EST 2010
Log message for revision 119004:
Don't allow "[\]^`" in DottedName.
https://bugs.launchpad.net/zope.schema/+bug/191236
Changed:
U zope.schema/trunk/CHANGES.txt
U zope.schema/trunk/src/zope/schema/_field.py
A zope.schema/trunk/src/zope/schema/tests/test_dotted_name.py
-=-
Modified: zope.schema/trunk/CHANGES.txt
===================================================================
--- zope.schema/trunk/CHANGES.txt 2010-12-19 12:32:35 UTC (rev 119003)
+++ zope.schema/trunk/CHANGES.txt 2010-12-19 13:00:57 UTC (rev 119004)
@@ -5,6 +5,8 @@
3.7.1 (unreleased)
------------------
+- Don't allow "[\]^`" in DottedName.
+ https://bugs.launchpad.net/zope.schema/+bug/191236
3.7.0 (2010-09-12)
------------------
Modified: zope.schema/trunk/src/zope/schema/_field.py
===================================================================
--- zope.schema/trunk/src/zope/schema/_field.py 2010-12-19 12:32:35 UTC (rev 119003)
+++ zope.schema/trunk/src/zope/schema/_field.py 2010-12-19 13:00:57 UTC (rev 119004)
@@ -629,8 +629,8 @@
_isdotted = re.compile(
- r"([a-zA-Z][a-zA-z0-9_]*)"
- r"([.][a-zA-Z][a-zA-z0-9_]*)*"
+ r"([a-zA-Z][a-zA-Z0-9_]*)"
+ r"([.][a-zA-Z][a-zA-Z0-9_]*)*"
# use the whole line
r"$").match
Added: zope.schema/trunk/src/zope/schema/tests/test_dotted_name.py
===================================================================
--- zope.schema/trunk/src/zope/schema/tests/test_dotted_name.py (rev 0)
+++ zope.schema/trunk/src/zope/schema/tests/test_dotted_name.py 2010-12-19 13:00:57 UTC (rev 119004)
@@ -0,0 +1,50 @@
+##############################################################################
+#
+# Copyright (c) 2010 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""DottedName field tests
+"""
+from unittest import main, makeSuite
+from zope.schema import DottedName
+from zope.schema.tests.test_field import FieldTestBase
+from zope.schema.interfaces import InvalidDottedName, RequiredMissing
+
+class DottedNameTest(FieldTestBase):
+ """Test the DottedName Field."""
+
+ _Field_Factory = DottedName
+
+ def testValidate(self):
+ field = self._Field_Factory(required=False)
+
+ field.validate(None)
+ field.validate('foo.bar')
+ field.validate('foo.bar0')
+ field.validate('foo0.bar')
+
+ # We used to incorrectly allow ^: https://bugs.launchpad.net/zope.schema/+bug/191236
+ self.assertRaises(InvalidDottedName, field.validate, 'foo.bar^foobar')
+ self.assertRaises(InvalidDottedName, field.validate, 'foo^foobar.bar')
+ # dotted names cannot start with digits
+ self.assertRaises(InvalidDottedName, field.validate, 'foo.0bar')
+ self.assertRaises(InvalidDottedName, field.validate, '0foo.bar')
+
+ def testValidateRequired(self):
+ field = self._Field_Factory(required=True)
+
+ field.validate('foo.bar')
+
+ self.assertRaises(RequiredMissing, field.validate, None)
+
+def test_suite():
+ suite = makeSuite(DottedNameTest)
+ return suite
Property changes on: zope.schema/trunk/src/zope/schema/tests/test_dotted_name.py
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the checkins
mailing list