You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/04/21 16:25:54 UTC

[24/25] allura git commit: [#7856] ticket:753 Handle emails in unexpected formats

[#7856] ticket:753 Handle emails in unexpected formats


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/8ea45a55
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/8ea45a55
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/8ea45a55

Branch: refs/heads/ib/7856
Commit: 8ea45a552b6c7cfe81ce277c1a4afe9d2bebed66
Parents: fb7f2cf
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Thu Apr 9 20:39:23 2015 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Apr 21 09:15:34 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py            | 7 +++++--
 Allura/allura/tests/model/test_auth.py | 2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8ea45a55/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 98dc4ec..8b06c73 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -169,8 +169,11 @@ class EmailAddress(MappedClass):
         if mo:
             addr = mo.group(1)
         if '@' in addr:
-            user, domain = addr.strip().split('@')
-            return '%s@%s' % (user, domain.lower())
+            try:
+                user, domain = addr.strip().split('@')
+                return '%s@%s' % (user, domain.lower())
+            except ValueError:
+                return addr.strip()
         else:
             return None
 

http://git-wip-us.apache.org/repos/asf/allura/blob/8ea45a55/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index eb7416c..4281bb1 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -105,6 +105,8 @@ def test_email_address_canonical():
                  'nobody@example.com')
     assert_equal(M.EmailAddress.canonical('  nobody@example.com\t'),
                  'nobody@example.com')
+    assert_equal(M.EmailAddress.canonical('I Am@Nobody <no...@example.com> '),
+                 'I Am@Nobody <no...@example.com>')
     assert_equal(M.EmailAddress.canonical('invalid'), None)
 
 @with_setup(setUp)