[Reportbug-maint] Bug#848692: reportbug fails with punctuation in name

Didier 'OdyX' Raboud odyx at debian.org
Tue Dec 27 13:07:09 UTC 2016


Package: reportbug
Version: 7.1.1
Tags: patch
Followup-For: Bug #848692

In reportbug/utils.py, there's a namespace collision between the "import
email" on line 38, and the use of 'email' as variable in the get_user_id
function, starting from line 282.

A possible patch is to rename 'email' to 'emailaddr' in get_user_id, see
attached patch.

Cheers,
	OdyX

-- Package-specific info:
** Environment settings:
DEBEMAIL="odyx at debian.org"
INTERFACE="text"

** /home/didier/.reportbugrc:
reportbug_version "7.1.1"
mode expert
ui text
realname "Didier 'OdyX' Raboud"
-------------- next part --------------
>From 8f7ae2aa6067b713c02004bbba174849ff513287 Mon Sep 17 00:00:00 2001
From: Didier Raboud <odyx at debian.org>
Date: Tue, 27 Dec 2016 13:56:36 +0100
Subject: [PATCH] In utils.py's get_user_id, replace email with emailaddr to
 avoid namespace collision with the 'email' package

Closes: #848692
---
 reportbug/utils.py | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/reportbug/utils.py b/reportbug/utils.py
index 89e0991..53244aa 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -279,25 +279,25 @@ def get_email(email='', realname=''):
     return get_email_addr(get_user_id(email, 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
+    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,12 @@ 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)
+        return '%s <%s>' % (realname, emailaddr)
 
-    addr = email.utils.formataddr((realname, email))
-
-    return addr
+    return email.utils.formataddr((realname, emailaddr))
 
 
 statuscache = {}
-- 
2.11.0



More information about the Reportbug-maint mailing list