Re: [BUG PATCH RFC] mailinfo: correctly handle multiline 'Subject:' header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 12, 2009 at 03:27:44PM -0800, Junio C Hamano wrote:
> Kirill Smelkov <kirr@xxxxxxxxxxxxxxxxxxx> writes:
> 
> > diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
> > index f7c8c08..6d72c1b 100644
> > --- a/builtin-mailinfo.c
> > +++ b/builtin-mailinfo.c
> > @@ -860,6 +860,7 @@ static void handle_info(void)
> >  			}
> >  			output_header_lines(fout, "Subject", hdr);
> >  		} else if (!memcmp(header[i], "From", 4)) {
> > +			cleanup_space(hdr);
> >  			handle_from(hdr);
> >  			fprintf(fout, "Author: %s\n", name.buf);
> >  			fprintf(fout, "Email: %s\n", email.buf);
> > diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox
> > index 4bf7947..d465685 100644
> > --- a/t/t5100/sample.mbox
> > +++ b/t/t5100/sample.mbox
> > @@ -2,7 +2,10 @@
> >  	
> >      
> >  From nobody Mon Sep 17 00:00:00 2001
> > -From: A U Thor <a.u.thor@xxxxxxxxxxx>
> > +From: A
> > +      U
> > +      Thor
> > +      <a.u.thor@xxxxxxxxxxx>
> >  Date: Fri, 9 Jun 2006 00:44:16 -0700
> >  Subject: [PATCH] a commit.
> 
> I think this is a reasonable change.

Thanks.


> But doesn't this
> 
> >  From nobody Mon Sep 17 00:00:00 2001
> > -From: A
> > +From: A (zzz)
> >        U
> >        Thor
> > -      <a.u.thor@xxxxxxxxxxx>
> > +      <a.u.thor@xxxxxxxxxxx> (Comment)
> 
> regress for people who spell their names like this?
> 
> 	From: john.doe@xxxxxxxx (John Doe)

I think everything is ok:

There is an explicit handler for such emails before my comments removal
in builtin-mailinfo.c:

        /* The remainder is name.  It could be "John Doe <john.doe@xz>"
         * or "john.doe@xz (John Doe)", but we have removed the
         * email part, so trim from both ends, possibly removing
         * the () pair at the end.
         */
        strbuf_trim(&f);
        if (f.buf[0] == '(' && f.len && f.buf[f.len - 1] == ')') {
                strbuf_remove(&f, 0, 1);
                strbuf_setlen(&f, f.len - 1);
        }


http://repo.or.cz/w/git.git?a=blob;f=builtin-mailinfo.c;h=f7c8c08b320c99d8bf96443ae57aa33c1de7e8c0;hb=HEAD#l112


And only a test for this is missing



>From 77316ad6db2c3b0f4be238c4ba855b2f785b50d6 Mon Sep 17 00:00:00 2001
From: Kirill Smelkov <kirr@xxxxxxxxxx>
Date: Tue, 13 Jan 2009 12:33:48 +0300
Subject: [PATCH] mailinfo: add explicit test for mails like '<a.u.thor@xxxxxxxxxxx> (A U Thor)'

Signed-off-by: Kirill Smelkov <kirr@xxxxxxxxxx>
---
 t/t5100-mailinfo.sh |    2 +-
 t/t5100/info0013    |    5 +++++
 t/t5100/sample.mbox |    5 +++++
 3 files changed, 11 insertions(+), 1 deletions(-)
 create mode 100644 t/t5100/info0013
 create mode 100644 t/t5100/msg0013
 create mode 100644 t/t5100/patch0013

diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index 625c204..e70ea94 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -11,7 +11,7 @@ test_expect_success 'split sample box' \
 	'git mailsplit -o. "$TEST_DIRECTORY"/t5100/sample.mbox >last &&
 	last=`cat last` &&
 	echo total is $last &&
-	test `cat last` = 12'
+	test `cat last` = 13'
 
 for mail in `echo 00*`
 do
diff --git a/t/t5100/info0013 b/t/t5100/info0013
new file mode 100644
index 0000000..bbe049e
--- /dev/null
+++ b/t/t5100/info0013
@@ -0,0 +1,5 @@
+Author: A U Thor
+Email: a.u.thor@xxxxxxxxxxx
+Subject: a patch
+Date: Fri, 9 Jun 2006 00:44:16 -0700
+
diff --git a/t/t5100/msg0013 b/t/t5100/msg0013
new file mode 100644
index 0000000..e69de29
diff --git a/t/t5100/patch0013 b/t/t5100/patch0013
new file mode 100644
index 0000000..e69de29
diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox
index 4f80b82..c5ad206 100644
--- a/t/t5100/sample.mbox
+++ b/t/t5100/sample.mbox
@@ -556,3 +556,8 @@ index 3fd3afb..0ee807e 100644
  #. п╫п╟ я│п╡п╬п╣п╧ п╪п╟я┬п╦п╫п╣: п╬я┌я─п╣п╢п╟п╨я┌п╦я─п╬п╡п╟я┌я▄ /etc/sudoers (п╨п╬п╪п╟п╫п╢п╟ ``visudo``) п©я─п╦п╪п╣я─п╫п╬ я│п╩п╣п╢я┐я▌я┴п╦п╪ п╬п╠я─п╟п╥п╬п╪::
 -- 
 1.5.6.5
+From nobody Mon Sep 17 00:00:00 2001
+From: <a.u.thor@xxxxxxxxxxx> (A U Thor)
+Date: Fri, 9 Jun 2006 00:44:16 -0700
+Subject: [PATCH] a patch
+
-- 
1.6.1.101.g0335

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux