[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 6.0-43-g2b254c9

Sandro Tosi morph at debian.org
Sun Aug 28 13:36:02 UTC 2011


The following commit has been merged in the master branch:
commit dbd9cb001af7e30ead5d12e4651ae857c8a4f842
Author: Sandro Tosi <morph at debian.org>
Date:   Sun Aug 28 12:17:02 2011 +0200

    use a POSIX lexer to parse configuration files so that escaping double quotes for 'realname' can be parsed correctly; thanks to Paul "TBBle" Hampson for the report; Closes: #579891

diff --git a/bin/reportbug b/bin/reportbug
index 3755476..859dbf2 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -569,8 +569,9 @@ def offer_configuration(options):
 
     realname = ui.get_string('What real name should be used for sending bug '
                              'reports?', default=realname, force_prompt=True)
-    if isinstance(realname, str):
+    if isinstance(realname, basestring):
         realname = realname.decode(charset, 'replace')
+        realname = realname.replace('"', '\\"')
 
     is_addr_ok = False
     while is_addr_ok != True:
diff --git a/debian/changelog b/debian/changelog
index 2632946..16f1fcd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -48,8 +48,12 @@ reportbug (6.2) UNRELEASED; urgency=low
     and the idea; Closes: #66917
   * reportbug/checkbuildd.py
     - fix buildd.d.o checks after the service changes layout; Closes: #612520
+  * bin/reportbug, reportbug/utils.py
+    - use a POSIX lexer to parse configuration files so that escaping double
+      quotes for 'realname' can be parsed correctly; thanks to Paul "TBBle"
+      Hampson for the report; Closes: #579891
 
- -- Sandro Tosi <morph at debian.org>  Sun, 28 Aug 2011 00:25:48 +0200
+ -- Sandro Tosi <morph at debian.org>  Sun, 28 Aug 2011 12:11:38 +0200
 
 reportbug (6.1) unstable; urgency=low
 
diff --git a/reportbug/utils.py b/reportbug/utils.py
index 17b9b27..f55345e 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -796,7 +796,7 @@ def get_cpu_cores():
 class our_lex(shlex.shlex):
     def get_token(self):
         token = shlex.shlex.get_token(self)
-        if not len(token): return token
+        if token is None or not len(token): return token
         if (token[0] == token[-1]) and token[0] in self.quotes:
             token = token[1:-1]
         return token
@@ -916,14 +916,15 @@ def parse_config_files():
     for filename in FILES:
         if os.path.exists(filename):
             try:
-                lex = our_lex(file(filename))
+                lex = our_lex(file(filename), posix=True)
             except IOError, msg:
                 continue
 
             lex.wordchars = lex.wordchars + '-.@/:<>'
 
-            token = lex.get_token().lower()
+            token = lex.get_token()
             while token:
+                token = token.lower()
                 if token in ('quiet', 'maintonly', 'submit'):
                     args['sendto'] = token
                 elif token == 'severity':
@@ -998,7 +999,7 @@ def parse_config_files():
                 else:
                     sys.stderr.write('Unrecognized token: %s\n' % token)
 
-                token = lex.get_token().lower()
+                token = lex.get_token()
 
     return args
 
diff --git a/test/test_utils.py b/test/test_utils.py
index 1d76d0d..b44755c 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -397,6 +397,13 @@ class TestConfig(unittest2.TestCase):
         args = utils.parse_config_files()
         self.assertIsNot(args, {})
 
+    def test_bts579891(self):
+        lex = utils.our_lex('realname "Paul \\"TBBle\\" Hampson"', posix=True)
+        option = lex.get_token()
+        self.assertEqual(option, 'realname')
+        realname = lex.get_token()
+        self.assertEqual(realname, 'Paul "TBBle" Hampson')
+
 
 class TestControl(unittest2.TestCase):
 

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list