aboutsummaryrefslogtreecommitdiff
path: root/test/multipart
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2011-05-31 15:39:26 -0700
committerCarl Worth <cworth@cworth.org>2011-05-31 15:39:26 -0700
commitc6b49ae752e642d779941a63bc65d5107e7010f1 (patch)
treefa39a8d0b9b68ff22494f1772af49ab5e9ea68fd /test/multipart
parent6ca7d73239091e8bff7cb05b145c6696d7b5d79a (diff)
test: Add test showing notmuch corrupts a part with a CRLF pair in it
Since commit 2f8871df6ea3c0b44f85a0fc1b4f58a6b70b0a0e notmuch has been using a function (show_part_content) originally written only for text parts to save all MIME parts. The problem with this is that this function converts CRLF pairs to LF only and optionally converts to UTF-8 encoding. These two conversions have the potential to corrupt binary data when passed through the function. This test demonstrates that corruption, and so fails currently, until we fix the bug.
Diffstat (limited to 'test/multipart')
-rwxr-xr-xtest/multipart37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/multipart b/test/multipart
index 1bcdfa2..c805078 100755
--- a/test/multipart
+++ b/test/multipart
@@ -56,6 +56,39 @@ W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
-----END PGP SIGNATURE-----
--==-=-=--
EOF
+
+cat <<EOF > ${MAIL_DIR}/base64-part-with-crlf
+From: Carl Worth <cworth@cworth.org>
+To: cworth@cworth.org
+Subject: Test message with a BASE64 encoded binary containing CRLF pair
+Date: Tue, 05 Jan 2001 15:43:57 -0000
+User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
+Message-ID: <base64-part-with-crlf>
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="==-=-=";
+
+--==-=-=
+
+The attached BASE64-encoded part expands to a binary containing a CRLF
+pair (that is one bye of 0x0D followed by one byte of 0x0A). This is
+designed to ensure that notmuch is not corrupting the output of this
+part by converting the CRLF pair to an LF only (as would be appropriate
+for display of a text part on a Linux system, for example).
+
+The part should be a 3-byte file with the following sequence of 3
+hexadecimal bytes:
+
+ EF 0D 0A
+
+--==-=-=
+Content-Type: application/octet-stream
+Content-Disposition: attachment; filename=crlf.bin
+Content-Transfer-Encoding: base64
+
+7w0K
+--==-=-=--
+EOF
+increment_mtime "$MAIL_DIR"
notmuch new > /dev/null
test_begin_subtest "--format=text --part=0, full message"
@@ -324,5 +357,9 @@ Non-text part: text/html
> -Carl
Non-text part: application/pgp-signature"
+test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"
+notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
+echo -n -e "\xEF\x0D\x0A" > crlf.expected
+test_expect_equal_file crlf.out crlf.expected
test_done