threads / discuss / 19902

git-mailsplit and TortoiseGit bugs

Subject: git-mailsplit and TortoiseGit bugs

## tl;dr

7 messages between Jun 22, 2009 and Jun 23, 2009.

replies: 6people: 4as markdown or json

Filip Navara· Jun 22, 2009, 17:53 UTC · lore
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· Jun 22, 2009, 20:29 UTC · re: Filip Navara · lore

Re: git-mailsplit and TortoiseGit bugs

On Mon, Jun 22, 2009 at 07:53:51PM +0200, Filip Navara wrote:
Show 9 quoted lines
> 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· Jun 22, 2009, 21:46 UTC · re: Jeff King · lore

Re: git-mailsplit and TortoiseGit bugs

On Mon, Jun 22, 2009 at 10:29 PM, Jeff King<peff@peff.net> wrote:
Show 20 quoted lines
> 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· Jun 23, 2009, 01:26 UTC · re: Filip Navara · lore

Re: git-mailsplit and TortoiseGit bugs

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>:
Show 34 quoted lines
> 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
>
Filip Navara· Jun 23, 2009, 08:13 UTC · re: Frank Li · lore

Re: git-mailsplit and TortoiseGit bugs

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.
Show 6 quoted lines
>
> Tortoisegit bug report:
> http://code.google.com/p/tortoisegit/issues/list
>
> best regards
> Frank Li

Best regards, Filip Navara

Jeff King· Jun 23, 2009, 04:42 UTC · re: Junio C Hamano · lore

Re: git-mailsplit and TortoiseGit bugs

On Mon, Jun 22, 2009 at 09:41:38PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> 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

← back to recent threads