2 ######################################################
4 # Test bogus headers (no blank line before body, etc.)
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname "$0"`/..
/..
12 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
15 .
"$MH_OBJ_DIR/test/common.sh"
19 expected
="$MH_TEST_DIR/$$.expected"
20 expected_err
="$MH_TEST_DIR/$$.expected_err"
21 actual
="$MH_TEST_DIR/$$.actual"
22 actual_err
="$MH_TEST_DIR/$$.actual_err"
24 # Write message with bogus header field (missing blank line, really).
25 msgfile
="$MH_TEST_DIR/Mail/inbox/11"
27 Date: Sun, 18 Dec 2005 00:52:39 +0100
31 This is a multi-part message in MIME format.
33 I am a stupid spammer.
38 cat >"$expected" <<EOF
39 11 12/18 foo@example.edu test<<This is a multi-part message in MIME format
41 run_prog scan
-width 80 last
> "$actual" 2>&1
42 check
"$expected" "$actual" : scan with bogus header field
46 cat >"$expected" <<EOF
49 Date: Sun, 18 Dec 2005 00:52:39 +0100
55 This is a multi-part message in MIME format.
57 I am a stupid spammer.
59 run_prog show last
> "$actual" 2>&1
60 check
"$expected" "$actual" : "show (mhl) with bogus header field"
64 cat >"$expected" <<EOF
66 Date: Sun, 18 Dec 2005 00:52:39 +0100
72 [ part - text/plain - 70B ]
74 This is a multi-part message in MIME format.
76 I am a stupid spammer.
78 run_prog mhshow last
> "$actual" 2>&1
79 check
"$expected" "$actual" : mhshow with bogus header field
81 # check m_getfld() handling of empty header field
82 start_test
'm_getfld() handling of empty header field'
83 msgfile
="$MH_TEST_DIR/Mail/inbox/12"
84 printf 'Date: Sat, 12 Jan 2013 09:07:01 -0600\nReceived:' >"$msgfile"
85 cat >"$expected" <<EOF
88 cat >"$expected_err" <<EOF
89 scan: eof encountered in field "Received"
90 ??Format error (message 12) in component 2
93 run_prog scan
-width 13 last
>"$actual" 2>"$actual_err"
94 check
"$expected" "$actual" : m_getfld
, empty header output
95 check
"$expected_err" "$actual_err" : m_getfld
, empty header error
97 # check m_getfld() handling of excessively long header field name
98 start_test
'm_getfld() handling of excessively long header field name'
99 msgfile
="$MH_TEST_DIR/Mail/inbox/13"
100 cat >"$msgfile" <<EOF
101 Date: Tue, 15 Jan 2013 21:13:12 -0600
102 ThisHeaderFieldNameIsWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaayTooLong: OK
104 cat >"$expected" <<EOF
108 run_prog scan
-width 13 last
>"$actual" 2>"$actual_err"
109 check
"$expected" "$actual" : m_getfld with excessively long header field name
110 # Cygwin has a BUFSIZ of 1024 so the error message gets truncated.
111 # Deal with that by grepping to verify that scan showed the proper error.
112 verify_string_in_file
() {
113 if grep "$1" "$2" >/dev
/null
; then
116 echo "$0: did not receive expected error message \"$1\""
117 failed
=`expr ${failed:-0} + 1`
120 verify_string_in_file
'scan: field name "ThisHeaderFieldNameIsWa' "$actual_err"
121 verify_string_in_file
'exceeds 997' "$actual_err"
122 verify_string_in_file
'??Format error (message 13) in component 2' "$actual_err"
125 # check m_getfld() handling of long header field name without a colon
126 start_test
'm_getfld() handling of long header field name without a colon'
127 msgfile
="$MH_TEST_DIR/Mail/inbox/14"
128 cat >"$msgfile" <<EOF
129 Date: Thu, 17 Jan 2013 19:33:46 -0600
130 If a header field name has at least 512 characters without a newline or colon, it will raise a format error in m_getfld(). Here is a test of that. 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
136 cat >"$expected" <<EOF
139 cat >"$expected_err" <<EOF
140 scan: eol encountered in field "If a header field name has at least 512 characters without a newline or colon, it will raise a format error in m_getfld(). Here is a test of that. 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901"
141 ??Format error (message 14) in component 2
144 run_prog scan
-width 13 last
>"$actual" 2>"$actual_err"
145 check
"$expected" "$actual" : m_getfld with long header
, no colon output
146 check
"$expected_err" "$actual_err" : m_getfld with long header
, no colon error