Add test to check for correct handling of long lines
authormarkus schnalke <meillo@marmaro.de>
Sun, 15 Jul 2018 11:28:13 +0000 (13:28 +0200)
committermarkus schnalke <meillo@marmaro.de>
Sun, 15 Jul 2018 11:28:13 +0000 (13:28 +0200)
test/tests/show/test-longlines [new file with mode: 0644]

diff --git a/test/tests/show/test-longlines b/test/tests/show/test-longlines
new file mode 100644 (file)
index 0000000..8079e4d
--- /dev/null
@@ -0,0 +1,107 @@
+#!/bin/sh
+######################################################
+#
+# Test long header line handling (998 chars)
+#
+######################################################
+
+set -e
+
+expected=$MH_TEST_DIR/$$.expected
+actual=$MH_TEST_DIR/$$.actual
+
+genlongsubject() {
+       len="${1:-998}"
+       awk -v len="$len" 'BEGIN {
+               prefix = "Subject: " len
+               while (i++<len) {
+                       s = s "x"
+               }
+               re = ".{" length(prefix) "}."
+               sub(re, prefix " ", s)
+               print s
+       }'
+}
+
+len=997
+
+# Write message with long header line
+msgfile=$(mhpath b)
+msgnum=$(basename $msgfile)
+cat > $msgfile <<-EOF
+From: foo@example.edu
+To: bar@example.edu
+`genlongsubject $len`
+Date: Sun, 15 Jul 2018 12:26:59 +0200
+
+foo
+EOF
+
+# check it
+cat > $expected <<-EOF
+Date:    Sun, 15 Jul 2018 12:26:59 +0200
+From:    foo@example.edu
+To:      bar@example.edu
+`genlongsubject $len`
+
+part       text/plain                   4
+foo
+EOF
+
+COLUMNS=2000 show $msgnum > $actual 2>&1
+diff -u $expected $actual
+
+
+len=998
+
+# Write message with long header line
+msgfile=$(mhpath b)
+msgnum=$(basename $msgfile)
+cat > $msgfile <<-EOF
+From: foo@example.edu
+To: bar@example.edu
+`genlongsubject $len`
+Date: Sun, 15 Jul 2018 12:26:59 +0200
+
+foo
+EOF
+
+# check it
+cat > $expected <<-EOF
+Date:    Sun, 15 Jul 2018 12:26:59 +0200
+From:    foo@example.edu
+To:      bar@example.edu
+`genlongsubject $len`
+
+part       text/plain                   4
+foo
+EOF
+
+COLUMNS=2000 show $msgnum > $actual 2>&1
+diff -u $expected $actual
+
+
+len=999
+
+# Write message with long header line
+msgfile=$(mhpath b)
+msgnum=$(basename $msgfile)
+cat > $msgfile <<-EOF
+From: foo@example.edu
+To: bar@example.edu
+`genlongsubject $len`
+Date: Sun, 15 Jul 2018 12:26:59 +0200
+
+foo
+EOF
+
+# check it
+cat > $expected <<-EOF
+mhl: format error in message 13
+part       text/plain                   4
+foo
+EOF
+
+COLUMNS=2000 show $msgnum > $actual 2>&1
+diff -u $expected $actual
+