]> diplodocus.org Git - nmh/blobdiff - test/mhbuild/test-ext-params
Replace strchr() condition with TrimSuffixC().
[nmh] / test / mhbuild / test-ext-params
index 58c2ff70e4c5a7eb605a76cc8c9da647601420e2..5be4514b43adee066eaaefba8e6ec72bd8ef7142 100755 (executable)
@@ -14,9 +14,10 @@ fi
 
 setup_test
 
 
 setup_test
 
-LC_ALL=en_US.UTF-8; export LC_ALL
+require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
 
 draft="$MH_TEST_DIR/$$.draft"
 
 draft="$MH_TEST_DIR/$$.draft"
+backup="${MH_TEST_DIR}/`mhparam sbackup`$$.draft.orig"
 expected="$MH_TEST_DIR/$$.expected"
 
 #
 expected="$MH_TEST_DIR/$$.expected"
 
 #
@@ -89,8 +90,8 @@ This is a test message
 ------- =_aaaaaaaaaa0
 Content-Type: image/jpeg
 Content-Disposition: attachment;
 ------- =_aaaaaaaaaa0
 Content-Type: image/jpeg
 Content-Disposition: attachment;
-       filename*0="This is an example of a rather long filename that is lon";
-       filename*1="ger than would fit on a normal line.jpg"
+       filename*0="This is an example of a rather long filename that is lo";
+       filename*1="nger than would fit on a normal line.jpg"
 Content-Transfer-Encoding: base64
 
 /9g=
 Content-Transfer-Encoding: base64
 
 /9g=
@@ -100,4 +101,154 @@ EOF
 
 check "$draft" "$expected"
 
 
 check "$draft" "$expected"
 
+#
+# Try out attach with a filename with 8-bit characters
+#
+
+cp "${srcdir}/test/mhbuild/tiny.jpg" "$MH_TEST_DIR/tïny.jpg"
+
+cat > "$draft" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+Attach: $MH_TEST_DIR/tïny.jpg
+------
+This is a test message
+EOF
+
+run_prog mhbuild "$draft"
+
+cat > "$expected" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii"
+
+This is a test message
+
+------- =_aaaaaaaaaa0
+Content-Type: image/jpeg; name*=UTF-8''t%C3%AFny.jpg
+Content-Description: =?UTF-8?B?dMOvbnkuanBn?=
+Content-Disposition: attachment; filename*=UTF-8''t%C3%AFny.jpg
+Content-Transfer-Encoding: base64
+
+/9g=
+
+------- =_aaaaaaaaaa0--
+EOF
+
+check "$draft" "$expected"
+
+#
+# Alternate version; specify a disposion, but not an explicit filename
+#
+
+cat > "$draft" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+------
+This is a test message
+#image/jpeg {attachment} $MH_TEST_DIR/tïny.jpg
+EOF
+
+run_prog mhbuild "$draft"
+
+cat > "$expected" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii"
+
+This is a test message
+
+------- =_aaaaaaaaaa0
+Content-Type: image/jpeg
+Content-Disposition: attachment; filename*=UTF-8''t%C3%AFny.jpg
+Content-Transfer-Encoding: base64
+
+/9g=
+
+------- =_aaaaaaaaaa0--
+EOF
+
+check "$draft" "$expected"
+
+#
+# Test to make sure things fail if we try to put 8-bit characters when the
+# locale is US-ASCII
+#
+
+cat > "$draft" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+------
+This is a test message
+#image/jpeg {attachment} $MH_TEST_DIR/tïny.jpg
+EOF
+
+old_locale="$LC_ALL"
+LC_ALL=C; export LC_ALL
+
+set +e
+run_test 'eval mhbuild "$draft" 2>&1' 'mhbuild: 8-bit characters in parameter "filename", but local character set is US-ASCII'
+set -e
+
+LC_ALL="$old_locale"; export LC_ALL
+
+rm -f "$MH_TEST_DIR/tïny.jpg"
+
+#
+# Test out message/external-body decoding
+#
+
+cat > "$draft" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+------
+This is a test message
+#@application/octet-stream [Test of a long URL] {attachment; \
+filename=test.tar.gz} access-type=url; url="http://www.example.com/this/is/an/example/of/a/very/long/url/that-should-be-wrapped/name.tar.gz"
+EOF
+
+run_prog mhbuild "$draft"
+
+cat > "$expected" <<EOF
+To: Mr Test <mrtest@example.com>
+cc:
+Fcc: +outbox
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="us-ascii"
+
+This is a test message
+
+------- =_aaaaaaaaaa0
+Content-Type: message/external-body; access-type="url";
+       url*0="http://www.example.com/this/is/an/example/of/a/very/long/url";
+       url*1="/that-should-be-wrapped/name.tar.gz"
+
+Content-Type: application/octet-stream
+Content-Description: Test of a long URL
+Content-Disposition: attachment; filename="test.tar.gz"
+
+------- =_aaaaaaaaaa0--
+EOF
+
+check "$draft" "$expected"
+
+[ ${failed:=0} -eq 0 ]  &&  rm -f ${backup}
+
 exit ${failed:-0}
 exit ${failed:-0}