Mercurial > hg > hg-git
changeset 539:7bf60690386c
Precompile Git username sanitizing regular expression
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 21 Sep 2012 19:36:57 -0700 |
parents | a38abdbab77c |
children | 3fb942852b1c |
files | hggit/git_handler.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -31,6 +31,8 @@ RE_GIT_AUTHOR = re.compile('^(.*?) ?\<(.*?)(?:\>(.*))?$') +RE_GIT_SANITIZE_AUTHOR = re.compile('[<>\n]') + # Test for git:// and git+ssh:// URI. # Support several URL forms, including separating the # host and path with either a / or : (sepr) @@ -435,7 +437,7 @@ >>> g('Typo in hgrc >but.hg-git@handles.it.gracefully>') 'Typo in hgrc ?but.hg-git@handles.it.gracefully' """ - return re.sub('[<>\n]', '?', name.lstrip('< ').rstrip('> ')) + return RE_GIT_SANITIZE_AUTHOR.sub('?', name.lstrip('< ').rstrip('> ')) def get_git_author(self, ctx): # hg authors might not have emails