Skip to content

Commit

Permalink
mailinfo: better parse email adresses containg parentheses
Browse files Browse the repository at this point in the history
When using git-rebase, author fields containing a ')' at the last position
had the close-parens character removed; the removal should be done only
when it is of this form:

        user@host (User Name)

i.e. the remainder after stripping the e-mail address part is enclosed in
a parentheses pair as a whole, not for addresses like this:

        User Name (me) <user@host>

Signed-off-by: Philippe Bruhat (BooK) <book@cpan.org>
Acked-by: Lukas Sandström <lukass@etek.chalmers.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Philippe Bruhat (BooK) authored and Junio C Hamano committed Jul 22, 2008
1 parent 75e1645 commit 0d4ede9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builtin-mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ static void handle_from(const struct strbuf *from)
* the () pair at the end.
*/
strbuf_trim(&f);
if (f.buf[0] == '(')
strbuf_remove(&name, 0, 1);
if (f.len && f.buf[f.len - 1] == ')')
if (f.buf[0] == '(' && f.len && f.buf[f.len - 1] == ')') {
strbuf_remove(&f, 0, 1);
strbuf_setlen(&f, f.len - 1);
}

get_sane_name(&name, &f, &email);
strbuf_release(&f);
Expand Down

0 comments on commit 0d4ede9

Please sign in to comment.