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.
37 cat >"$expected" <<EOF
38 11 12/18 foo@example.edu test<<This is a multi-part message in MIME format
40 run_prog scan
-width 80 last
> "$actual" 2>&1
41 check
"$expected" "$actual" : scan with bogus header field
44 cat >"$expected" <<EOF
47 Date: Sun, 18 Dec 2005 00:52:39 +0100
53 This is a multi-part message in MIME format.
55 I am a stupid spammer.
57 run_prog show last
> "$actual" 2>&1
58 check
"$expected" "$actual" : "show (mhl) with bogus header field"
61 cat >"$expected" <<EOF
63 Date: Sun, 18 Dec 2005 00:52:39 +0100
69 [ part - text/plain - 70B ]
71 This is a multi-part message in MIME format.
73 I am a stupid spammer.
75 run_prog mhshow last
> "$actual" 2>&1
76 check
"$expected" "$actual" : mhshow with bogus header field
78 # check m_getfld() handling of empty header field
79 msgfile
="$MH_TEST_DIR/Mail/inbox/12"
80 printf 'Date: Sat, 12 Jan 2013 09:07:01 -0600\nReceived:' >"$msgfile"
81 cat >"$expected" <<EOF
84 cat >"$expected_err" <<EOF
85 scan: eof encountered in field "Received"
86 ??Format error (message 12) in component 2
89 run_prog scan
-width 13 last
>"$actual" 2>"$actual_err"
90 check
"$expected" "$actual" : m_getfld
, empty header output
91 check
"$expected_err" "$actual_err" : m_getfld
, empty header error
93 # check m_getfld() handling of excessively long header field name
94 ms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aaaaaaaaaaaaaaaaaayTooLong: OK
99 cat >"$expected" <<EOF
103 run_prog scan
-width 13 last
>"$actual" 2>"$actual_err"
104 check
"$expected" "$actual" : m_getfld with excessively long header field name
105 # Cygwin has a BUFSIZ of 1024 so the error message gets truncated.
106 # Deal with that by grepping to verify that scan showed the proper error.
107 verify_string_in_file
() {
108 if grep "$1" "$2" >/dev
/null
; then
111 echo "$0: did not receive expected error message \"$1\""
112 failed
=`expr ${failed:-0} + 1`
115 verify_string_in_file
'scan: field name "ThisHeaderFieldNameIsWa' "$actual_err"
116 verify_string_in_file
'exceeds 997' "$actual_err"
117 verify_string_in_file
'??Format error (message 13) in component 2' "$actual_err"
120 # check m_getfld() handling of long header field name without a colon
121 msgfile
="$MH_TEST_DIR/Mail/inbox/14"
122 cat >"$msgfile" <<EOF
123 Date: Thu, 17 Jan 2013 19:33:46 -0600
124 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
130 cat >"$expected" <<EOF
133 cat >"$expected_err" <<EOF
134 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"
135 ??Format error (message 14) in component 2
138 run_prog scan
-width 13 last
>"$actual" 2>"$actual_err"
139 check
"$expected" "$actual" : m_getfld with long header
, no colon output
140 check
"$expected_err" "$actual_err" : m_getfld with long header
, no colon error