From 85336f97775e8c1718538a9831ed8ecb72426627 Mon Sep 17 00:00:00 2001 From: Jay Shirley Date: Fri, 8 Aug 2014 09:11:05 -0700 Subject: [PATCH 1/2] Relax the RegEx restrictions to allow the new ICAAN TLDs. --- AUTHORS | 1 + mongoengine/fields.py | 4 ++-- tests/fields/fields.py | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 81ec2f76..57035505 100644 --- a/AUTHORS +++ b/AUTHORS @@ -206,3 +206,4 @@ that much better: * Clay McClure (https://github.com/claymation) * Bruno Rocha (https://github.com/rochacbruno) * Norberto Leite (https://github.com/nleite) + * Jay Shirley (https://github.com/jshirley) diff --git a/mongoengine/fields.py b/mongoengine/fields.py index 7bbc221a..80421c15 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -160,8 +160,8 @@ class EmailField(StringField): r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # quoted-string r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' - # domain - r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,253}[A-Z0-9])?\.)+[A-Z]{2,6}$', re.IGNORECASE + # domain (max length of an ICAAN TLD is 22 characters) + r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,253}[A-Z0-9])?\.)+[A-Z]{2,22}$', re.IGNORECASE ) def validate(self, value): diff --git a/tests/fields/fields.py b/tests/fields/fields.py index 0af22a34..69d78ff8 100644 --- a/tests/fields/fields.py +++ b/tests/fields/fields.py @@ -2902,6 +2902,9 @@ class FieldTest(unittest.TestCase): "aJIazqqWkm7.net")) self.assertTrue(user.validate() is None) + user = User(email="new-tld@example.technology") + self.assertTrue(user.validate() is None) + user = User(email='me@localhost') self.assertRaises(ValidationError, user.validate) From 1c5898d39615ab7caef5a73602c2c008f6147b3f Mon Sep 17 00:00:00 2001 From: Jay Shirley Date: Tue, 19 Aug 2014 15:54:29 -0700 Subject: [PATCH 2/2] Adding changelog entry. --- docs/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index c543c4d8..c36b281e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -47,6 +47,7 @@ Changes in 0.9.X - DEV - Conditional save for atomic-style operations #511 - Allow dynamic dictionary-style field access #559 - index_cls is ignored when deciding to set _cls as index prefix #733 +- Increase email field length to accommodate new TLDs #726 Changes in 0.8.7 ================