[Reportbug-commits] [reportbug] 01/02: fix the 'email' name clash in reportbug.utils functions by renaming their arguments to 'emailaddr', this fixes names with special characters in the address; patch by Didier 'OdyX' Raboud; Closes: #848692
Sandro Tosi
morph at moszumanska.debian.org
Thu Jan 5 00:40:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository reportbug.
commit e5dc19b88f1e2a5e99a507fbc21505b44af2ff7e
Author: Sandro Tosi <morph at debian.org>
Date: Wed Jan 4 19:18:56 2017 -0500
fix the 'email' name clash in reportbug.utils functions by renaming their arguments to 'emailaddr', this fixes names with special characters in the address; patch by Didier 'OdyX' Raboud; Closes: #848692
---
debian/changelog | 9 +++++++++
reportbug/utils.py | 29 ++++++++++++-----------------
test/test_utils.py | 6 ++++++
3 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index dd2e766..39b3045 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+reportbug (7.1.2) UNRELEASED; urgency=medium
+
+ * reportbug/utils.py
+ - fix the 'email' name clash in reportbug.utils functions by renaming their
+ arguments to 'emailaddr', this fixes names with special characters in the
+ address; patch by Didier 'OdyX' Raboud; Closes: #848692
+
+ -- Sandro Tosi <morph at debian.org> Wed, 04 Jan 2017 19:07:00 -0500
+
reportbug (7.1.1) unstable; urgency=medium
* Upload to unstable
diff --git a/reportbug/utils.py b/reportbug/utils.py
index 89e0991..8adcae1 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -275,29 +275,29 @@ def get_email_addr(addr):
return email.utils.getaddresses([addr,])[0]
-def get_email(email='', realname=''):
- return get_email_addr(get_user_id(email, realname))
+def get_email(emailaddr='', realname=''):
+ return get_email_addr(get_user_id(emailaddr, realname))
-def get_user_id(email='', realname='', charset='utf-8'):
+def get_user_id(emailaddr='', realname='', charset='utf-8'):
uid = os.getuid()
info = pwd.getpwuid(uid)
- email = (os.environ.get('REPORTBUGEMAIL', email) or
- os.environ.get('DEBEMAIL') or os.environ.get('EMAIL'))
+ emailaddr = (os.environ.get('REPORTBUGEMAIL', emailaddr) or
+ os.environ.get('DEBEMAIL') or os.environ.get('EMAIL'))
- email = email or find_rewritten(info[0]) or info[0]
+ emailaddr = emailaddr or find_rewritten(info[0]) or info[0]
- if '@' not in email:
+ if '@' not in emailaddr:
if os.path.exists('/etc/mailname'):
domainname = open('/etc/mailname').readline().strip()
else:
domainname = socket.getfqdn()
- email = email + '@' + domainname
+ emailaddr = emailaddr + '@' + domainname
# Handle EMAIL if it's formatted as 'Bob <bob at host>'.
- if '<' in email or '(' in email:
- realname, email = get_email_addr(email)
+ if '<' in emailaddr or '(' in emailaddr:
+ realname, emailaddr = get_email_addr(emailaddr)
if not realname:
realname = (os.environ.get('DEBFULLNAME') or os.environ.get('DEBNAME')
@@ -308,14 +308,9 @@ def get_user_id(email='', realname='', charset='utf-8'):
realname = realname.replace('&', info[0].upper())
if not realname:
- return email
+ return emailaddr
- if re.match(r'[\w\s]+$', realname):
- return '%s <%s>' % (realname, email)
-
- addr = email.utils.formataddr((realname, email))
-
- return addr
+ return email.utils.formataddr((realname, emailaddr))
statuscache = {}
diff --git a/test/test_utils.py b/test/test_utils.py
index 700b81a..fcc74b0 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -65,6 +65,12 @@ class TestEmail(unittest.TestCase):
addr = utils.get_user_id(mail)
self.assertIn(mail, addr)
+ def test_bts848692(self):
+ name = "name-with.special`chars' "
+ mail = 'nomail at nodomain.ext'
+ addr = utils.get_user_id(mail, name)
+ self.assertEqual(addr, '"%s" <%s>' % (name, mail))
+
def test_find_rewritten(self):
unittest.skip("Is utils.find_rewritten actually useful to someone? deprecate it?")
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reportbug/reportbug.git
More information about the Reportbug-commits
mailing list