# git-mailsplit and TortoiseGit bugs

7 messages from 2009-06-22 to 2009-06-23. Participants: Filip Navara, Jeff King, Frank Li, Junio C Hamano.
Thread: https://gitlist.dev/t/19902

## Filip Navara, 2009-06-22 17:53

Subject: git-mailsplit and TortoiseGit bugs
Message-ID: <5b31733c0906221053k4b2659bev1da861b8e997eb5f@mail.gmail.com>
URL: https://gitlist.dev/e/5b31733c0906221053k4b2659bev1da861b8e997eb5f%40mail.gmail.com

```
Hello,

I'd like to report a bug. There's an incompatibility between the way
TortoiseGit sends patches by e-mail and their handling by
git-mailsplit. The mail sent by TortoiseGit specifies the Content-Type
header as "Content-Type: text/plain;
boundary=WC_MAIL_PaRt_BoUnDaRy_05151998". git-mailsplit then
misinterprets it and treats it as empty patch. While TortoiseGit
should not be sending the boundary parameter, it is perfectly valid
e-mail according to RFC 5322 and MIME RFCs. The "boundary" parameter
should be ignored for anything but "multipart" Content-Types.

Best regards,
Filip Navara

P.S. I'm not subscribed to the mailing lists, so please CC me if you reply.

```

## Jeff King, 2009-06-22 20:29

Subject: Re: git-mailsplit and TortoiseGit bugs
Message-ID: <20090622202939.GA11912@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20090622202939.GA11912%40sigill.intra.peff.net
In-Reply-To: <5b31733c0906221053k4b2659bev1da861b8e997eb5f@mail.gmail.com>

```
On Mon, Jun 22, 2009 at 07:53:51PM +0200, Filip Navara wrote:

> I'd like to report a bug. There's an incompatibility between the way
> TortoiseGit sends patches by e-mail and their handling by
> git-mailsplit. The mail sent by TortoiseGit specifies the Content-Type
> header as "Content-Type: text/plain;
> boundary=WC_MAIL_PaRt_BoUnDaRy_05151998". git-mailsplit then
> misinterprets it and treats it as empty patch. While TortoiseGit
> should not be sending the boundary parameter, it is perfectly valid
> e-mail according to RFC 5322 and MIME RFCs. The "boundary" parameter
> should be ignored for anything but "multipart" Content-Types.

That seems like a bug in TortoiseGit, and I don't know if it is worth
git trying to work around problems in something that is not even close
to a 1.0 version.

Still, it is good to be liberal in what we accept. So maybe the patch
below is worth applying (I assume from your description it will fix the
problem you are having, but I didn't actually test it with TortoiseGit;
please confirm that it helps).

-- >8 --
mailinfo: accept useless non-multipart boundary attributes

There is no reason for a program generating a patch email to
add a "boundary" parameter to a text/plain (or any other
non-multipart) content type. However, at least one version
of TortoiseGit does so, confusing git-mailinfo, which looks
for and fails to find the boundary.

This patch causes mailinfo to respect boundary parameters
only for multipart/* content types, and simply ignore the
parameter otherwise.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin-mailinfo.c            |    3 ++-
 t/t5100-mailinfo.sh           |   13 +++++++++++++
 t/t5100/boundary.in           |   20 ++++++++++++++++++++
 t/t5100/boundary.msg.expect   |    2 ++
 t/t5100/boundary.out.expect   |    5 +++++
 t/t5100/boundary.patch.expect |   11 +++++++++++
 6 files changed, 53 insertions(+), 1 deletions(-)
 create mode 100644 t/t5100/boundary.in
 create mode 100644 t/t5100/boundary.msg.expect
 create mode 100644 t/t5100/boundary.out.expect
 create mode 100644 t/t5100/boundary.patch.expect

diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 92637ac..3e9dbe0 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -184,7 +184,8 @@ static void handle_content_type(struct strbuf *line)
 
 	if (!strcasestr(line->buf, "text/"))
 		 message_type = TYPE_OTHER;
-	if (slurp_attr(line->buf, "boundary=", boundary)) {
+	if (strcasestr(line->buf, "multipart/") &&
+	    slurp_attr(line->buf, "boundary=", boundary)) {
 		strbuf_insert(boundary, 0, "--", 2);
 		if (++content_top > &content[MAX_BOUNDARIES]) {
 			fprintf(stderr, "Too many boundaries to handle\n");
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index e70ea94..e67ce55 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -77,4 +77,17 @@ test_expect_success 'mailinfo on from header without name works' '
 
 '
 
+test_expect_success 'mailinfo on text message with useless boundary' '
+
+	mkdir boundary &&
+	git mailsplit -oboundary "$TEST_DIRECTORY"/t5100/boundary.in &&
+	test_cmp "$TEST_DIRECTORY"/t5100/boundary.in boundary/0001 &&
+	git mailinfo boundary/msg boundary/patch \
+	  <boundary/0001 >boundary/out &&
+	test_cmp "$TEST_DIRECTORY"/t5100/boundary.out.expect boundary/out &&
+	test_cmp "$TEST_DIRECTORY"/t5100/boundary.msg.expect boundary/msg &&
+	test_cmp "$TEST_DIRECTORY"/t5100/boundary.patch.expect boundary/patch
+
+'
+
 test_done
diff --git a/t/t5100/boundary.in b/t/t5100/boundary.in
new file mode 100644
index 0000000..367ed7d
--- /dev/null
+++ b/t/t5100/boundary.in
@@ -0,0 +1,20 @@
+From nobody Mon Sep 17 00:00:00 2001
+From: A U Thor <a.u.thor@example.com>
+Date: Fri, 9 Jun 2006 00:44:16 -0700
+Subject: [PATCH] a commit
+MIME-Version: 1.0
+Content-Type: text/plain; boundary="totally_useless"
+
+Commit message.
+
+---
+ foo |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/foo b/foo
+index 9123cdc..918dcf8 100644
+--- a/foo
++++ b/foo
+@@ -1 +1 @@
+-Fri Jun  9 00:44:04 PDT 2006
++Fri Jun  9 00:44:13 PDT 2006
diff --git a/t/t5100/boundary.msg.expect b/t/t5100/boundary.msg.expect
new file mode 100644
index 0000000..550aef5
--- /dev/null
+++ b/t/t5100/boundary.msg.expect
@@ -0,0 +1,2 @@
+Commit message.
+
diff --git a/t/t5100/boundary.out.expect b/t/t5100/boundary.out.expect
new file mode 100644
index 0000000..f247b6f
--- /dev/null
+++ b/t/t5100/boundary.out.expect
@@ -0,0 +1,5 @@
+Author: A U Thor
+Email: a.u.thor@example.com
+Subject: a commit
+Date: Fri, 9 Jun 2006 00:44:16 -0700
+
diff --git a/t/t5100/boundary.patch.expect b/t/t5100/boundary.patch.expect
new file mode 100644
index 0000000..bd32624
--- /dev/null
+++ b/t/t5100/boundary.patch.expect
@@ -0,0 +1,11 @@
+---
+ foo |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/foo b/foo
+index 9123cdc..918dcf8 100644
+--- a/foo
++++ b/foo
+@@ -1 +1 @@
+-Fri Jun  9 00:44:04 PDT 2006
++Fri Jun  9 00:44:13 PDT 2006
-- 
1.6.3.2.406.gd6a466.dirty

```

## Filip Navara, 2009-06-22 21:46

Subject: Re: git-mailsplit and TortoiseGit bugs
Message-ID: <5b31733c0906221446m1a82b39fkd5d25ea413697138@mail.gmail.com>
URL: https://gitlist.dev/e/5b31733c0906221446m1a82b39fkd5d25ea413697138%40mail.gmail.com
In-Reply-To: <20090622202939.GA11912@sigill.intra.peff.net>

```
On Mon, Jun 22, 2009 at 10:29 PM, Jeff King<peff@peff.net> wrote:
> On Mon, Jun 22, 2009 at 07:53:51PM +0200, Filip Navara wrote:
>
>> I'd like to report a bug. There's an incompatibility between the way
>> TortoiseGit sends patches by e-mail and their handling by
>> git-mailsplit. The mail sent by TortoiseGit specifies the Content-Type
>> header as "Content-Type: text/plain;
>> boundary=WC_MAIL_PaRt_BoUnDaRy_05151998". git-mailsplit then
>> misinterprets it and treats it as empty patch. While TortoiseGit
>> should not be sending the boundary parameter, it is perfectly valid
>> e-mail according to RFC 5322 and MIME RFCs. The "boundary" parameter
>> should be ignored for anything but "multipart" Content-Types.
>
> That seems like a bug in TortoiseGit, and I don't know if it is worth
> git trying to work around problems in something that is not even close
> to a 1.0 version.
>
> Still, it is good to be liberal in what we accept. So maybe the patch
> below is worth applying (I assume from your description it will fix the
> problem you are having, but I didn't actually test it with TortoiseGit;
> please confirm that it helps).

Yes, this patch helps. While TortoiseGit shouldn't send the parameter
in the first place it's still prefectly valid e-mail that should be
accepted. Of course I will report it in the TortoiseGit issue tracker
for fixing.

Thanks,
Filip Navara

```

## Frank Li, 2009-06-23 01:26

Subject: Re: git-mailsplit and TortoiseGit bugs
Message-ID: <1976ea660906221826lfc074c2x6231dcae16535a9c@mail.gmail.com>
URL: https://gitlist.dev/e/1976ea660906221826lfc074c2x6231dcae16535a9c%40mail.gmail.com
In-Reply-To: <5b31733c0906221446m1a82b39fkd5d25ea413697138@mail.gmail.com>

```
Do you means I should remove "boundary=WC_MAIL_PaRt_BoUnDaRy_05151998"
when send patch without attachment?

Tortoisegit bug report:
http://code.google.com/p/tortoisegit/issues/list

best regards
Frank Li

2009/6/23 Filip Navara <filip.navara@gmail.com>:
> On Mon, Jun 22, 2009 at 10:29 PM, Jeff King<peff@peff.net> wrote:
>> On Mon, Jun 22, 2009 at 07:53:51PM +0200, Filip Navara wrote:
>>
>>> I'd like to report a bug. There's an incompatibility between the way
>>> TortoiseGit sends patches by e-mail and their handling by
>>> git-mailsplit. The mail sent by TortoiseGit specifies the Content-Type
>>> header as "Content-Type: text/plain;
>>> boundary=WC_MAIL_PaRt_BoUnDaRy_05151998". git-mailsplit then
>>> misinterprets it and treats it as empty patch. While TortoiseGit
>>> should not be sending the boundary parameter, it is perfectly valid
>>> e-mail according to RFC 5322 and MIME RFCs. The "boundary" parameter
>>> should be ignored for anything but "multipart" Content-Types.
>>
>> That seems like a bug in TortoiseGit, and I don't know if it is worth
>> git trying to work around problems in something that is not even close
>> to a 1.0 version.
>>
>> Still, it is good to be liberal in what we accept. So maybe the patch
>> below is worth applying (I assume from your description it will fix the
>> problem you are having, but I didn't actually test it with TortoiseGit;
>> please confirm that it helps).
>
> Yes, this patch helps. While TortoiseGit shouldn't send the parameter
> in the first place it's still prefectly valid e-mail that should be
> accepted. Of course I will report it in the TortoiseGit issue tracker
> for fixing.
>
> Thanks,
> Filip Navara
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```

## Junio C Hamano, 2009-06-23 04:41

Subject: Re: git-mailsplit and TortoiseGit bugs
Message-ID: <7vskhra7el.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vskhra7el.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20090622202939.GA11912@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> mailinfo: accept useless non-multipart boundary attributes

Is this "accept"? Or do you mean "ignore"?

```

## Jeff King, 2009-06-23 04:42

Subject: Re: git-mailsplit and TortoiseGit bugs
Message-ID: <20090623044258.GA26875@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090623044258.GA26875%40coredump.intra.peff.net
In-Reply-To: <7vskhra7el.fsf@alter.siamese.dyndns.org>

```
On Mon, Jun 22, 2009 at 09:41:38PM -0700, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > mailinfo: accept useless non-multipart boundary attributes
> 
> Is this "accept"? Or do you mean "ignore"?

Saying "ignore" is probably more accurate.

-Peff

```

## Filip Navara, 2009-06-23 08:13

Subject: Re: git-mailsplit and TortoiseGit bugs
Message-ID: <5b31733c0906230113u518cbd96t4ab825d83eafbe8a@mail.gmail.com>
URL: https://gitlist.dev/e/5b31733c0906230113u518cbd96t4ab825d83eafbe8a%40mail.gmail.com
In-Reply-To: <1976ea660906221826lfc074c2x6231dcae16535a9c@mail.gmail.com>

```
On Tue, Jun 23, 2009 at 3:26 AM, Frank Li<lznuaa@gmail.com> wrote:
> Do you means I should remove "boundary=WC_MAIL_PaRt_BoUnDaRy_05151998"
> when send patch without attachment?

Yes, it's meaningless for text/plain mails.

>
> Tortoisegit bug report:
> http://code.google.com/p/tortoisegit/issues/list
>
> best regards
> Frank Li

Best regards,
Filip Navara

```
