[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.9-64-g52467de

Sandro Tosi morph at debian.org
Sat Mar 6 16:44:20 UTC 2010


The following commit has been merged in the master branch:
commit a42b86281639cc794f2c7eb3794da094d8a1705a
Author: Carl Chenet <carl.chenet at ohmytux.com>
Date:   Fri Jun 5 00:30:23 2009 +0200

    check if the email address is correct

diff --git a/bin/reportbug b/bin/reportbug
index 842b1c5..075ec4c 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -553,12 +553,17 @@ def offer_configuration(options):
     if isinstance(realname, str):
         realname = realname.decode(charset, 'replace')
 
-    from_addr = ui.get_string(
-        'Which of your email addresses should be used when sending bug '
-        'reports? (Note that this address will be visible in the bug tracking '
-        'system, so you may want to use a webmail address or another address '
-        'with good spam filtering capabilities.)',
-        default=(options.email or def_email), force_prompt=True)
+    is_addr_ok = False
+    while is_addr_ok != True:
+        from_addr = ui.get_string(
+            'Which of your email addresses should be used when sending bug '
+            'reports? (Note that this address will be visible in the bug tracking '
+            'system, so you may want to use a webmail address or another address '
+            'with good spam filtering capabilities.)',
+            default=(options.email or def_email), force_prompt=True)
+        is_addr_ok = utils.check_email_addr(from_addr)
+        if not is_addr_ok:
+            ewrite('Your email address is not valid; please try another one.\n')
 
     stupidmode = not ui.yes_no(
         'Do you have a "mail transport agent" (MTA) like Exim, Postfix or '
@@ -932,6 +937,12 @@ def main():
 
     # check if attachment files exist, else exiting
     # all are checked, and it doesn't exit at the first missing
+
+    if options.email:
+        if not utils.check_email_addr(options.email):
+            ewrite('Your email address is not valid; exiting.\n')
+            sys.exit(1)
+
     if options.attachments:
         any_missing = False
         for attachment in options.attachments:
diff --git a/reportbug/utils.py b/reportbug/utils.py
index 3655904..9d78826 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -211,6 +211,20 @@ def find_rewritten(username):
                     print 'Invalid entry in %s' % filename
                     return None
 
+def check_email_addr(addr):
+    if '@' not in addr:
+        return False
+    if addr.count('@') != 1:
+        return False
+    localpart, domainpart = addr.split('@')
+    if localpart.startswith('.') or localpart.endswith('.'):
+        return False
+    if '.' not in domainpart:
+        return False
+    if domainpart.startswith('.') or domainpart.endswith('.'):
+        return False
+    return True
+
 def get_email_addr(addr):
     addr = rfc822.AddressList(addr)
     return addr.addresslist[0]

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list