Bug#848692: reportbug fails with punctuation in name

2017-01-04 Thread Sandro Tosi
On Wed, Dec 21, 2016 at 9:24 PM, brian m. carlson
 wrote:
> The issue is this code:
>
> if re.match(r'[\w\s]+
> , realname):
> return '%s <%s>' % (realname, email)
>
> addr = email.utils.formataddr((realname, email))
>
> We don't take the branch since “.” (and “'”, etc.) are not in [\w\s],
> and then we throw an exception as email is not the module imported at
> the top, but the local variable.


I just removed that first if, as email.utils.formataddr() is more than
able to deal with all the special cases, we dont need to do that too,
thx!

-- 
Sandro "morph" Tosi
My website: http://sandrotosi.me/
Me at Debian: http://wiki.debian.org/SandroTosi
G+: https://plus.google.com/u/0/+SandroTosi



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

2017-01-04 Thread Sandro Tosi
> A possible patch is to rename 'email' to 'emailaddr' in get_user_id, see
> attached patch.

Thanks Didier, i'm going to apply your patch soon!

-- 
Sandro "morph" Tosi
My website: http://sandrotosi.me/
Me at Debian: http://wiki.debian.org/SandroTosi
G+: https://plus.google.com/u/0/+SandroTosi



Bug#848692: reportbug fails with punctuation in name

2016-12-27 Thread Didier 'OdyX' Raboud
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="o...@debian.org"
INTERFACE="text"

** /home/didier/.reportbugrc:
reportbug_version "7.1.1"
mode expert
ui text
realname "Didier 'OdyX' Raboud"
>From 8f7ae2aa6067b713c02004bbba174849ff513287 Mon Sep 17 00:00:00 2001
From: Didier Raboud 
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 '.
-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



Bug#848692: reportbug fails with punctuation in name

2016-12-21 Thread brian m. carlson
package reportbug
retitle 848692 reportbug fails with punctuation in name
severity 848692 important
kthxbye

This issue hit me as well, seeing as I use a middle initial, and
therefore have a period in my realname field.  I'm raising the severity
to important, although I could argue based on one's inability to choose
one's name, this could be grave.

The issue is this code:

if re.match(r'[\w\s]+$', realname):
return '%s <%s>' % (realname, email)

addr = email.utils.formataddr((realname, email))

We don't take the branch since “.” (and “'”, etc.) are not in [\w\s],
and then we throw an exception as email is not the module imported at
the top, but the local variable.  As the original reporter and I
discovered, omitting the punctuation from one's name makes things work,
as the branch is then taken.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204


signature.asc
Description: PGP signature