You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/04/21 19:43:23 UTC
[2/2] 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/1acc5f38
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1acc5f38
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1acc5f38
Branch: refs/heads/master
Commit: 1acc5f38f47d38683016d8f569bbd047765b2c8b
Parents: d162d67
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Thu Apr 9 20:39:23 2015 +0300
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Tue Apr 21 13:40:49 2015 -0400
----------------------------------------------------------------------
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/1acc5f38/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/1acc5f38/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)