]> diplodocus.org Git - nmh/blobdiff - test/mhshow/test-textcharset
Wrapped uses of %{charset} in mhn.defaults with double quotes.
[nmh] / test / mhshow / test-textcharset
index 61522c4eca5af640e0b1fccdf9da49f28f60fae9..78500a5dbbbed0863387b5b939e52f267e0694f2 100755 (executable)
@@ -20,13 +20,14 @@ if test "$ICONV_ENABLED" -eq 0; then
   test_skip 'test-textcharset requires that nmh have been built with iconv'
 fi
 
-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
 
 expected="$MH_TEST_DIR"/$$.expected
 actual="$MH_TEST_DIR"/$$.actual
 
 # check charset conversion
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -39,7 +40,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 4 =F7 2 =3D 2
 EOF
 
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -47,12 +49,12 @@ Subject: test display with charset conversion
 
 MIME-Version: 1.0
 
-part       text/plain                  11
+[ part  - text/plain -   11B  ]
 4 รท 2 = 2
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check charset conversion
 
 cat >>"$MH" <<'EOF'
 mhshow-show-text/plain: echo %{charset}
@@ -61,6 +63,7 @@ EOF
 
 # check expansion of %{charset} by itself
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -73,7 +76,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 4 =F7 2 =3D 2
 EOF
 
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -85,11 +89,13 @@ UTF-8
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check %{charset} by itself
 
 
 # check expansion of empty %{charset} by itself
 msgfile=`mhpath new`
+omsgnum=$msgnum
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -102,7 +108,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 4 =F7 2 =3D 2
 EOF
 
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -114,7 +121,7 @@ MIME-Version: 1.0
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check empty %{charset} by itself
 
 
 grep -v 'mhshow-show-text/plain:' "$MH" >"$MH.new"
@@ -124,7 +131,8 @@ mhshow-show-text/plain: charset=%{charset}; echo ${charset:+-I $charset}
 EOF
 
 # check expansion of embedded %{charset} with no text following
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$omsgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -135,12 +143,13 @@ MIME-Version: 1.0
 -I UTF-8
 EOF
 
-run_prog mhshow prev >"$actual" 2>&1
-check "$expected" "$actual"
+run_prog mhshow prev >"$actual" 2>&1   # NB:  "mhshow prev" !!!
+check "$expected" "$actual" : check embedded %{charset} with no text
 
 
 # check expansion of empty embedded %{charset} with no text following
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -152,14 +161,15 @@ MIME-Version: 1.0
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check empty embedded %{charset} with no text following
 
 
 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'
+cat >"$expected" <<EOF
+[ Message inbox:$omsgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -170,12 +180,13 @@ MIME-Version: 1.0
 -I UTF-8 file
 EOF
 
-run_prog mhshow prev >"$actual" 2>&1
-check "$expected" "$actual"
+run_prog mhshow prev >"$actual" 2>&1   # NB:  "mhshow prev" !!!
+check "$expected" "$actual" : check embedded %{charset} with text following
 
 
 # check expansion of empty embedded %{charset} with text following
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -187,7 +198,7 @@ file
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check empty embedded %{charset} with text following
 
 
 sed -e 's/charset/method/g' "$MH" >"$MH.new"
@@ -195,6 +206,7 @@ mv -f "$MH.new" "$MH"
 
 # check parameter value quoting
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -207,7 +219,10 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 4 =F7 2 =3D 2
 EOF
 
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
+EOF
+cat >>"$expected" <<'EOF'
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -219,7 +234,7 @@ MIME-Version: 1.0
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check parameter value quoting
 
 
 sed -e 's/method/unknown/g' "$MH" >"$MH.new"
@@ -227,6 +242,7 @@ mv -f "$MH.new" "$MH"
 
 # check that unknown parameter is not expanded
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -239,7 +255,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 4 =F7 2 =3D 2
 EOF
 
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -251,7 +268,7 @@ file
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : check unknown parameter is not expanded
 
 
 grep -v '^mhshow-show-text/plain: ' "$MH" >>"$MH.new"
@@ -262,6 +279,7 @@ EOF
 
 # check parameter value quoting with text following
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -273,7 +291,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100
 This is a test.
 EOF
 
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -284,7 +303,24 @@ MIME-Version: 1.0
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : parameter value quoting with text following
+
+# check malicious parameter value quoting
+msgfile=`mhpath new`
+msgnum=`basename $msgfile`
+cat >"$msgfile" <<'EOF'
+Subject: shows difficulty of quoting with /bin/sh -c
+MIME-Version: 1.0
+Content-Type: text/html; charset="oops'; echo should not see this!"
+
+EOF
+
+cat >"$expected" <<EOF
+[ part  - text/html -   0B  ]
+EOF
+
+run_prog mhshow -noheader -form mhl.null last >"$actual" 2>&1
+check "$expected" "$actual" : malicious parameter value quoting
 
 #
 # test a large file that needs to be converted to UTF-8
@@ -293,6 +329,7 @@ check "$expected" "$actual"
 grep -v '^mhshow-show-text/plain: ' "$MH" >>"$MH.new"
 mv -f "$MH.new" "$MH"
 msgfile=`mhpath new`
+msgnum=`basename $msgfile`
 cat >"$msgfile" <<'EOF'
 From: foo@example.edu
 To: bar@example.edu
@@ -727,7 +764,8 @@ one of the glass buildings.
 =93How strange!=94 she exclaimed, drawing a long breath.
 EOF
 
-cat >"$expected" <<'EOF'
+cat >"$expected" <<EOF
+[ Message inbox:$msgnum ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 To:      bar@example.edu
 From:    foo@example.edu
@@ -735,7 +773,7 @@ Subject: check charset conversion of a large file
 
 MIME-Version: 1.0
 
-part       text/plain                 18K
+[ part  - text/plain -   18.9KB  ]
 1.  The Earthquake
 
 
@@ -1154,6 +1192,6 @@ one of the glass buildings.
 EOF
 
 run_prog mhshow last >"$actual" 2>&1
-check "$expected" "$actual"
+check "$expected" "$actual" : large file conversion to UTF-8
 
 exit $failed