From: markus schnalke <meillo@marmaro.de>
Date: Sun, 15 Jul 2018 11:28:13 +0000 (+0200)
Subject: Add test to check for correct handling of long lines
X-Git-Tag: mmh-0.4~29
X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=220857595d567997752e7e10279882ceac9516ae;p=mmh

Add test to check for correct handling of long lines
---

diff --git a/test/tests/show/test-longlines b/test/tests/show/test-longlines
new file mode 100644
index 00000000..8079e4db
--- /dev/null
+++ b/test/tests/show/test-longlines
@@ -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
+