summaryrefslogtreecommitdiff
path: root/t/t5100/sample.mbox
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2008-08-09 01:17:24 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-08-09 01:26:35 -0700
commita9fd1383a73878284d4157b20ac7c735e876102e (patch)
tree79120c2528ed7f6396c666cf8a3d5bd3c01c9b6b /t/t5100/sample.mbox
parentbuiltin-rm: Add a --force flag (diff)
downloadtgif-a9fd1383a73878284d4157b20ac7c735e876102e.tar.xz
mailinfo: fix MIME multi-part message boundary handling
After finding a MIME multi-part message boundary line, the handle_body() function is supposed to first flush any accumulated contents from the previous part to the output stream. However, the code mistakenly output the boundary line it found. The old code that used one global, fixed-length buffer line[] used an alternate static buffer newline[] for keeping track of this accumulated contents and flushed newline[] upon seeing the boundary; when 3b6121f (git-mailinfo: use strbuf's instead of fixed buffers, 2008-07-13) converted a fixed-length buffer in this program to use strbuf,these two buffers were converted to "line" and "prev" (the latter of which now has a much more sensible name) strbufs, but the code mistakenly flushed "line" (which contains the boundary we have just found), instead of "prev". This resulted in the first boundary to be output in front of the first line of the message. The rewritten implementation of handle_boundary() lost the terminating newline; this would then result in the second line of the message to be stuck with the first line. The is_multipart_boundary() was designed to catch both the internal boundary and the terminating one (the one with trailing "--"); this also was broken with the rewrite, and the code in the handle_boundary() to handle the terminating boundary was never triggered. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5100/sample.mbox')
-rw-r--r--t/t5100/sample.mbox35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox
index aba57f922b..d7ca79b1fc 100644
--- a/t/t5100/sample.mbox
+++ b/t/t5100/sample.mbox
@@ -465,3 +465,38 @@ index 962aa34..2d1520f 100644
--
1.5.6.2.455.g1efb2
+From nobody Fri Aug 8 22:24:03 2008
+Date: Fri, 8 Aug 2008 13:08:37 +0200 (CEST)
+From: A U Thor <a.u.thor@example.com>
+Subject: [PATCH 3/3 v2] Xyzzy
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="=-=-="
+
+--=-=-=
+Content-Type: text/plain; charset=iso-8859-15
+Content-Transfer-Encoding: quoted-printable
+
+Here comes a commit log message, and
+its second line is here.
+---
+ builtin-mailinfo.c | 4 ++--
+
+diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
+index 3e5fe51..aabfe5c 100644
+--- a/builtin-mailinfo.c
++++ b/builtin-mailinfo.c
+@@ -758,8 +758,8 @@ static void handle_body(void)
+ /* process any boundary lines */
+ if (*content_top && is_multipart_boundary(&line)) {
+ /* flush any leftover */
+- if (line.len)
+- handle_filter(&line);
++ if (prev.len)
++ handle_filter(&prev);
+=20
+ if (!handle_boundary())
+ goto handle_body_out;
+--=20
+1.6.0.rc2
+
+--=-=-=--