diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-12-27 23:52:26 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-12-27 23:52:26 +0100 |
commit | 9df9e3770a15b47e48f8218eed6d68ebcb5eed6c (patch) | |
tree | ff84f3faaf9aff72b00c7b7229509e4ecfae2d9e /mailinfo.c | |
parent | Merge branch 'ps/chainlint-self-check-update' (diff) | |
parent | mailinfo: avoid recursion when unquoting From headers (diff) | |
download | git-9df9e3770a15b47e48f8218eed6d68ebcb5eed6c.tar.xz git-9df9e3770a15b47e48f8218eed6d68ebcb5eed6c.zip |
Merge branch 'jk/mailinfo-iterative-unquote-comment'
The code to parse the From e-mail header has been updated to avoid
recursion.
* jk/mailinfo-iterative-unquote-comment:
mailinfo: avoid recursion when unquoting From headers
t5100: make rfc822 comment test more careful
Diffstat (limited to 'mailinfo.c')
-rw-r--r-- | mailinfo.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mailinfo.c b/mailinfo.c index 9681864216..94b9b0abf2 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -59,6 +59,7 @@ static void parse_bogus_from(struct mailinfo *mi, const struct strbuf *line) static const char *unquote_comment(struct strbuf *outbuf, const char *in) { int take_next_literally = 0; + int depth = 1; strbuf_addch(outbuf, '('); @@ -72,11 +73,14 @@ static const char *unquote_comment(struct strbuf *outbuf, const char *in) take_next_literally = 1; continue; case '(': - in = unquote_comment(outbuf, in); + strbuf_addch(outbuf, '('); + depth++; continue; case ')': strbuf_addch(outbuf, ')'); - return in; + if (!--depth) + return in; + continue; } } |