Escape the unusual characters in the name <email> strings
authorCatalin Marinas <catalin.marinas@gmail.com>
Mon, 3 Oct 2005 17:33:49 +0000 (18:33 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Mon, 3 Oct 2005 17:33:49 +0000 (18:33 +0100)
Otherwise there are problems when passing the environment to git-commit.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/common.py

index 68bd39b..4e4a79f 100644 (file)
@@ -117,7 +117,8 @@ def name_email(string):
     """Return a tuple consisting of the name and email parsed from a
     standard 'name <email>' string
     """
-    str_list = re.findall('^(.*)\s+<(.*)>$', string)
+    string = re.sub('([^\w\s<>@.])', '\\\\\\1', string)
+    str_list = re.findall('^(.*)\s*<(.*)>\s*$', string)
     if not str_list:
         raise CmdException, 'Incorrect "name <email>" string: %s' % string
 
@@ -127,7 +128,8 @@ def name_email_date(string):
     """Return a tuple consisting of the name, email and date parsed
     from a 'name <email> date' string
     """
-    str_list = re.findall('^(.*)\s+<(.*)>\s+(.*)$', string)
+    string = re.sub('([^\w\s<>@.])', '\\\\\\1', string)
+    str_list = re.findall('^(.*)\s*<(.*)>\s*(.*)\s*$', string)
     if not str_list:
         raise CmdException, 'Incorrect "name <email> date" string: %s' % string