Skip to content

Commit 9df9e37

Browse files
committed
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
2 parents f6a129c + dee1829 commit 9df9e37

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

mailinfo.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static void parse_bogus_from(struct mailinfo *mi, const struct strbuf *line)
5959
static const char *unquote_comment(struct strbuf *outbuf, const char *in)
6060
{
6161
int take_next_literally = 0;
62+
int depth = 1;
6263

6364
strbuf_addch(outbuf, '(');
6465

@@ -72,11 +73,14 @@ static const char *unquote_comment(struct strbuf *outbuf, const char *in)
7273
take_next_literally = 1;
7374
continue;
7475
case '(':
75-
in = unquote_comment(outbuf, in);
76+
strbuf_addch(outbuf, '(');
77+
depth++;
7678
continue;
7779
case ')':
7880
strbuf_addch(outbuf, ')');
79-
return in;
81+
if (!--depth)
82+
return in;
83+
continue;
8084
}
8185
}
8286

t/t5100/comment.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Author: A U Thor (this is (really) a comment (honestly))
1+
Author: (this is (really) a "comment" (honestly)) A U Thor
22
33
Subject: testing comments
44
Date: Sun, 25 May 2008 00:38:18 -0700

t/t5100/comment.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
From 1234567890123456789012345678901234567890 Mon Sep 17 00:00:00 2001
2-
From: "A U Thor" <[email protected]> (this is \(really\) a comment (honestly))
2+
From: (this is \(really\) a "comment" (honestly)) "A U Thor" <[email protected]>
33
Date: Sun, 25 May 2008 00:38:18 -0700
44
Subject: [PATCH] testing comments
55

0 commit comments

Comments
 (0)