| 1 |
#!/bin/sh |
| 2 |
###################################################### |
| 3 |
# |
| 4 |
# Test show of one part, fixed by |
| 5 |
# 31cba404636730df219dd009ca5893ccc56d46af |
| 6 |
# |
| 7 |
###################################################### |
| 8 |
|
| 9 |
set -e |
| 10 |
|
| 11 |
if test -z "${MH_OBJ_DIR}"; then |
| 12 |
srcdir=`dirname "$0"`/../.. |
| 13 |
MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR |
| 14 |
fi |
| 15 |
|
| 16 |
. "$MH_OBJ_DIR/test/common.sh" |
| 17 |
|
| 18 |
setup_test |
| 19 |
|
| 20 |
expected=$MH_TEST_DIR/$$.expected |
| 21 |
actual=$MH_TEST_DIR/$$.actual |
| 22 |
|
| 23 |
mhn_defaults="$MH_INST_DIR${nmhetcdir}/mhn.defaults" |
| 24 |
|
| 25 |
if grep mhfixmsg-format-text/html "${mhn_defaults}" >/dev/null; then |
| 26 |
can_reformat_texthtml=1 |
| 27 |
if grep 'mhfixmsg-format-text/html.*w3m' "${mhn_defaults}" \ |
| 28 |
>/dev/null; then |
| 29 |
#### w3m uses $HOME/.w3m/, and creates it if it doesn't exist. To |
| 30 |
#### support testing with non-writeable $HOME, and to not leave |
| 31 |
#### relics from this test if it is writeable but doesn't already |
| 32 |
#### have a .w3m, and to not depend on whatever is in that if it |
| 33 |
#### does already exist, overwrite $HOME if using w3m. |
| 34 |
HOME="$MHTMPDIR"; export HOME |
| 35 |
fi |
| 36 |
else |
| 37 |
echo "$0: skipping html checks because no text browser was found" |
| 38 |
can_reformat_texthtml=0 |
| 39 |
fi |
| 40 |
|
| 41 |
# Write message with a text/plain subpart. |
| 42 |
msgfile=`mhpath new` |
| 43 |
msgnum=`basename $msgfile` |
| 44 |
cat > $msgfile <<EOF |
| 45 |
MIME-Version: 1.0 |
| 46 |
Content-Type: multipart/mixed; boundary="NextPart_001" |
| 47 |
Content-class: urn:content-classes:message |
| 48 |
Date: Thu, 19 May 2011 00:00:00 -0000 |
| 49 |
From: [email protected] |
| 50 |
To: [email protected] |
| 51 |
|
| 52 |
This is a multi-part message in MIME format. |
| 53 |
|
| 54 |
--NextPart_001 |
| 55 |
Content-Type: multipart/related; |
| 56 |
type="multipart/alternative"; |
| 57 |
boundary="NextPart_002" |
| 58 |
|
| 59 |
--NextPart_002 |
| 60 |
Content-Type: text/plain; |
| 61 |
charset="utf-8" |
| 62 |
|
| 63 |
This is the text/plain part. |
| 64 |
|
| 65 |
--NextPart_002-- |
| 66 |
|
| 67 |
--NextPart_001-- |
| 68 |
EOF |
| 69 |
|
| 70 |
# Write the expected output. |
| 71 |
cat > $expected <<EOF |
| 72 |
[ Message inbox:11 ] |
| 73 |
[ part 1.1 - text/plain - 29B ] |
| 74 |
This is the text/plain part. |
| 75 |
EOF |
| 76 |
|
| 77 |
# check it |
| 78 |
start_test 'text/plain part' |
| 79 |
run_prog mhshow -part 1.1 -form mhl.null $msgnum > $actual 2>&1 |
| 80 |
check "$expected" "$actual" : part 1.1 |
| 81 |
|
| 82 |
|
| 83 |
# tests of -part/-type/-prefer |
| 84 |
|
| 85 |
cat > $msgfile <<EOF |
| 86 |
To: [email protected] |
| 87 |
From: someone <[email protected]> |
| 88 |
Subject: mhshow -part/-type/-prefer test |
| 89 |
Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT) |
| 90 |
Content-Type: multipart/mixed; boundary="BoundaryMixed" |
| 91 |
|
| 92 |
--BoundaryMixed |
| 93 |
Content-type: multipart/alternative; |
| 94 |
boundary="BoundaryAlternative1" |
| 95 |
|
| 96 |
--BoundaryAlternative1 |
| 97 |
Content-type: text/plain; charset=US-ASCII; format=flowed |
| 98 |
Content-transfer-encoding: 8bit |
| 99 |
|
| 100 |
This is the body text/plain part. |
| 101 |
--BoundaryAlternative1 |
| 102 |
Content-type: multipart/related; |
| 103 |
boundary="BoundaryAlternative2"; type="text/html" |
| 104 |
|
| 105 |
--BoundaryAlternative2 |
| 106 |
Content-type: text/html; CHARSET=US-ASCII |
| 107 |
Content-transfer-encoding: quoted-printable |
| 108 |
|
| 109 |
<html><body><div><span style=3D"line-height: 1.5;"> |
| 110 |
This is the text/html body part. |
| 111 |
</span></div></body></html> |
| 112 |
|
| 113 |
--BoundaryAlternative2-- |
| 114 |
|
| 115 |
--BoundaryAlternative1-- |
| 116 |
|
| 117 |
--BoundaryMixed |
| 118 |
Content-Type: text/plain; charset="us-ascii" |
| 119 |
MIME-Version: 1.0 |
| 120 |
Content-Transfer-Encoding: 7bit |
| 121 |
Content-Disposition: inline |
| 122 |
|
| 123 |
_______________________________________________ |
| 124 |
This is the final text/plain signature part. |
| 125 |
|
| 126 |
--BoundaryMixed-- |
| 127 |
EOF |
| 128 |
|
| 129 |
# Write the expected output. |
| 130 |
if [ $can_reformat_texthtml -eq 1 ]; then |
| 131 |
cat > $expected <<EOF |
| 132 |
[ Message inbox:11 ] |
| 133 |
[ part 1.1.1 - text/html - 111B ] |
| 134 |
This is the text/html body part. |
| 135 |
EOF |
| 136 |
|
| 137 |
# check it |
| 138 |
start_test 'text/html part' |
| 139 |
run_prog mhshow -part 1.1.1 -form mhl.null $msgnum 2>&1 | |
| 140 |
squeeze_whitespace >$actual |
| 141 |
check "$expected" "$actual" : part 1.1.1 |
| 142 |
fi |
| 143 |
|
| 144 |
# Write the expected output. |
| 145 |
cat > $expected <<EOF |
| 146 |
[ Message inbox:11 ] |
| 147 |
[ part 1.2 - text/plain - 33B ] |
| 148 |
This is the body text/plain part. |
| 149 |
EOF |
| 150 |
|
| 151 |
# check it |
| 152 |
start_test 'text/plain alternative part' |
| 153 |
run_prog mhshow -part 1.2 -form mhl.null $msgnum > $actual 2>&1 |
| 154 |
check "$expected" "$actual" : part 1.2 |
| 155 |
|
| 156 |
# Write the expected output. |
| 157 |
cat > $expected <<EOF |
| 158 |
[ Message inbox:11 ] |
| 159 |
[ part 1.1 - text/plain - 33B ] |
| 160 |
This is the body text/plain part. |
| 161 |
EOF |
| 162 |
|
| 163 |
# check it |
| 164 |
start_test 'conflicting text/plain, part 1 switches' |
| 165 |
run_prog mhshow -prefer text/plain -part 1 -form mhl.null $msgnum > $actual 2>&1 |
| 166 |
check "$expected" "$actual" : part conflicting text/plain, part 1 switches |
| 167 |
|
| 168 |
# Write the expected output. |
| 169 |
cat > $expected <<EOF |
| 170 |
[ Message inbox:11 ] |
| 171 |
[ part 2 - text/plain - 93B ] |
| 172 |
_______________________________________________ |
| 173 |
This is the final text/plain signature part. |
| 174 |
EOF |
| 175 |
|
| 176 |
# check it |
| 177 |
start_test 'final text/plain part' |
| 178 |
run_prog mhshow -part 2 -form mhl.null $msgnum > $actual 2>&1 |
| 179 |
check "$expected" "$actual" : part 2 |
| 180 |
|
| 181 |
# Write the expected output. |
| 182 |
cat > $expected <<EOF |
| 183 |
[ Message inbox:11 ] |
| 184 |
[ part 1.2 - text/plain - 33B ] |
| 185 |
This is the body text/plain part. |
| 186 |
[ part 2 - text/plain - 93B ] |
| 187 |
_______________________________________________ |
| 188 |
This is the final text/plain signature part. |
| 189 |
EOF |
| 190 |
|
| 191 |
# check it |
| 192 |
start_test 'all text/plain parts' |
| 193 |
run_prog mhshow -type text/plain -form mhl.null $msgnum > $actual 2>&1 |
| 194 |
check "$expected" "$actual" : type text/plain |
| 195 |
|
| 196 |
# Write the expected output. |
| 197 |
cat > $expected <<EOF |
| 198 |
[ Message inbox:11 ] |
| 199 |
[ part 1.1 - text/plain - 33B ] |
| 200 |
This is the body text/plain part. |
| 201 |
[ part 2 - text/plain - 93B ] |
| 202 |
_______________________________________________ |
| 203 |
This is the final text/plain signature part. |
| 204 |
EOF |
| 205 |
|
| 206 |
start_test 'prefer text/plain' |
| 207 |
run_prog mhshow -prefer text/plain -form mhl.null $msgnum > $actual 2>&1 |
| 208 |
check "$expected" "$actual" : prefer text/plain |
| 209 |
|
| 210 |
|
| 211 |
finish_test |
| 212 |
exit $failed |