X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/721b0395fb2fceac4e66fed1009ed2f17fd5351f..19bf8698eeb0ab3d7694232af115fa3f007d5c7b:/test/mhshow/test-textcharset diff --git a/test/mhshow/test-textcharset b/test/mhshow/test-textcharset index b80802f1..5fc07e6e 100755 --- a/test/mhshow/test-textcharset +++ b/test/mhshow/test-textcharset @@ -17,15 +17,17 @@ fi setup_test if test "$ICONV_ENABLED" -eq 0; then - echo "$0: skipping test-textcharset because nmh was built without iconv" - exit 0 + test_skip 'test-textcharset requires that nmh have been built with iconv' fi +LC_ALL=en_US.UTF-8; export LC_ALL + expected="$MH_TEST_DIR"/$$.expected actual="$MH_TEST_DIR"/$$.actual +# check charset conversion msgfile=`mhpath new` -cat >"$msgfile" <"$msgfile" <<'EOF' From: foo@example.edu To: bar@example.edu Subject: test display with charset conversion @@ -37,8 +39,7 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100 4 =F7 2 =3D 2 EOF -# Check -notextcharset. -cat >"$expected" <"$expected" <<'EOF' Date: Sun, 18 Dec 2005 00:52:39 +0100 To: bar@example.edu From: foo@example.edu @@ -46,30 +47,244 @@ Subject: test display with charset conversion MIME-Version: 1.0 +part text/plain 11 +4 ÷ 2 = 2 EOF -run_prog mhshow -textcharset UTF-8 -notextcharset -nopause last >"$actual" 2>&1 +run_prog mhshow last >"$actual" 2>&1 check "$expected" "$actual" -# Check -textcharset. -cat >"$expected" <>"$MH" <<'EOF' +mhshow-show-text/plain: echo %{charset} +EOF + + +# check expansion of %{charset} by itself +msgfile=`mhpath new` +cat >"$msgfile" <<'EOF' +From: foo@example.edu +To: bar@example.edu +Subject: test display with %{charset} expansion +MIME-Version: 1.0 +Content-Type: text/plain; charset=windows-1252 +Content-Transfer-Encoding: quoted-printable +Date: Sun, 18 Dec 2005 00:52:39 +0100 + +4 =F7 2 =3D 2 +EOF + +cat >"$expected" <<'EOF' Date: Sun, 18 Dec 2005 00:52:39 +0100 To: bar@example.edu From: foo@example.edu -Subject: test display with charset conversion +Subject: test display with %{charset} expansion MIME-Version: 1.0 -part text/plain 10 -4 ÷ 2 = 2 +UTF-8 EOF -run_prog mhshow -textcharset UTF-8 -nopause last >"$actual" 2>&1 -check "$expected" "$actual" 'keep first' +run_prog mhshow last >"$actual" 2>&1 +check "$expected" "$actual" -# Check use of user's locale. -LC_ALL=en_US.UTF-8; export LC_ALL -run_prog mhshow -nopause last >"$actual" 2>&1 + +# check expansion of empty %{charset} by itself +msgfile=`mhpath new` +cat >"$msgfile" <<'EOF' +From: foo@example.edu +To: bar@example.edu +Subject: test display with empty %{charset} expansion +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable +Date: Sun, 18 Dec 2005 00:52:39 +0100 + +4 =F7 2 =3D 2 +EOF + +cat >"$expected" <<'EOF' +Date: Sun, 18 Dec 2005 00:52:39 +0100 +To: bar@example.edu +From: foo@example.edu +Subject: test display with empty %{charset} expansion + +MIME-Version: 1.0 + + +EOF + +run_prog mhshow last >"$actual" 2>&1 +check "$expected" "$actual" + + +grep -v 'mhshow-show-text/plain:' "$MH" >"$MH.new" +mv -f "$MH.new" "$MH" +cat >>"$MH" <<'EOF' +mhshow-show-text/plain: charset=%{charset}; echo ${charset:+-I $charset} +EOF + +# check expansion of embedded %{charset} with no text following +cat >"$expected" <<'EOF' +Date: Sun, 18 Dec 2005 00:52:39 +0100 +To: bar@example.edu +From: foo@example.edu +Subject: test display with %{charset} expansion + +MIME-Version: 1.0 + +-I UTF-8 +EOF + +run_prog mhshow prev >"$actual" 2>&1 +check "$expected" "$actual" + + +# check expansion of empty embedded %{charset} with no text following +cat >"$expected" <<'EOF' +Date: Sun, 18 Dec 2005 00:52:39 +0100 +To: bar@example.edu +From: foo@example.edu +Subject: test display with empty %{charset} expansion + +MIME-Version: 1.0 + + +EOF + +run_prog mhshow last >"$actual" 2>&1 +check "$expected" "$actual" + + +sed -e 's%\(mhshow-show-text/plain:.*\)%\1 file%' "$MH" >"$MH.new" +mv -f "$MH.new" "$MH" + +# check expansion of embedded %{charset} with text following +cat >"$expected" <<'EOF' +Date: Sun, 18 Dec 2005 00:52:39 +0100 +To: bar@example.edu +From: foo@example.edu +Subject: test display with %{charset} expansion + +MIME-Version: 1.0 + +-I UTF-8 file +EOF + +run_prog mhshow prev >"$actual" 2>&1 check "$expected" "$actual" + +# check expansion of empty embedded %{charset} with text following +cat >"$expected" <<'EOF' +Date: Sun, 18 Dec 2005 00:52:39 +0100 +To: bar@example.edu +From: foo@example.edu +Subject: test display with empty %{charset} expansion + +MIME-Version: 1.0 + +file +EOF + +run_prog mhshow last >"$actual" 2>&1 +check "$expected" "$actual" + + +sed -e 's/charset/method/g' "$MH" >"$MH.new" +mv -f "$MH.new" "$MH" + +# check parameter value quoting +msgfile=`mhpath new` +cat >"$msgfile" <<'EOF' +From: foo@example.edu +To: bar@example.edu +Subject: test C-T parameter expansion quoting +MIME-Version: 1.0 +Content-Type: text/plain; method=$QUOTEME' +Content-Transfer-Encoding: quoted-printable +Date: Sun, 18 Dec 2005 00:52:39 +0100 + +4 =F7 2 =3D 2 +EOF + +cat >"$expected" <<'EOF' +Date: Sun, 18 Dec 2005 00:52:39 +0100 +To: bar@example.edu +From: foo@example.edu +Subject: test C-T parameter expansion quoting + +MIME-Version: 1.0 + +-I $QUOTEME' file +EOF + +run_prog mhshow last >"$actual" 2>&1 +check "$expected" "$actual" + + +sed -e 's/method/unknown/g' "$MH" >"$MH.new" +mv -f "$MH.new" "$MH" + +# check that unknown parameter is not expanded +msgfile=`mhpath new` +cat >"$msgfile" <<'EOF' +From: foo@example.edu +To: bar@example.edu +Subject: test display with unknown C-T parameter expansion +MIME-Version: 1.0 +Content-Type: text/plain; charset=windows-1252 +Content-Transfer-Encoding: quoted-printable +Date: Sun, 18 Dec 2005 00:52:39 +0100 + +4 =F7 2 =3D 2 +EOF + +cat >"$expected" <<'EOF' +Date: Sun, 18 Dec 2005 00:52:39 +0100 +To: bar@example.edu +From: foo@example.edu +Subject: test display with unknown C-T parameter expansion + +MIME-Version: 1.0 + +file +EOF + +run_prog mhshow last >"$actual" 2>&1 +check "$expected" "$actual" + + +grep -v '^mhshow-show-text/plain: ' "$MH" >>"$MH.new" +mv -f "$MH.new" "$MH" +cat >>"$MH" <"$msgfile" <<'EOF' +From: foo@example.edu +To: bar@example.edu +Subject: check parameter value quoting with text following +MIME-Version: 1.0 +Content-Type: text/plain +Date: Sun, 18 Dec 2005 00:52:39 +0100 + +This is a test. +EOF + +cat >"$expected" <<'EOF' +Date: Sun, 18 Dec 2005 00:52:39 +0100 +To: bar@example.edu +From: foo@example.edu +Subject: check parameter value quoting with text following + +MIME-Version: 1.0 + +EOF + +run_prog mhshow last >"$actual" 2>&1 +check "$expected" "$actual" + + exit $failed