aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas <lucas@sexy.is>2022-01-25 13:08:37 +0000
committerLeah Neukirchen <leah@vuxu.org>2022-01-25 14:22:06 +0100
commite951b0ba27f878e4daa09c59a89e8f5196e31e07 (patch)
tree2807a477a22df8adc0870d4bd4b6ab4d47d5da30
parentfa27d73ddd379f185a426c3ee44319a9a4fb50ae (diff)
downloadmblaze-e951b0ba27f878e4daa09c59a89e8f5196e31e07.tar.gz
mblaze-e951b0ba27f878e4daa09c59a89e8f5196e31e07.tar.xz
mblaze-e951b0ba27f878e4daa09c59a89e8f5196e31e07.zip
mmime: allow to relax body line length limit
Message-Id: <10e22a318b5c70d89432d85ecd8cb8ce1796a51d.1643116719.git.lucas@sexy.is>
-rw-r--r--man/mmime.17
-rw-r--r--mmime.c3
-rwxr-xr-xt/1000-mmime.t12
3 files changed, 20 insertions, 2 deletions
diff --git a/man/mmime.1 b/man/mmime.1
index 8fbf26b..618f126 100644
--- a/man/mmime.1
+++ b/man/mmime.1
@@ -46,6 +46,13 @@ Override Content-Type for the toplevel part.
Defaults to
.Sq Li multipart/mixed .
.El
+.Sh ENVIRONMENT
+.Bl -tag -width Ds
+.It Ev MBLAZE_RELAXED_MIME
+If set,
+.Ic Nm Fl c
+will relax the body line length check and only consider bodies with lines
+longer than 998 characters need to be MIME formatted.
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
diff --git a/mmime.c b/mmime.c
index f082cf0..ab5bcf4 100644
--- a/mmime.c
+++ b/mmime.c
@@ -517,6 +517,7 @@ check()
off_t linelen = 0;
off_t maxheadlinelen = 0;
off_t maxbodylinelen = 0;
+ off_t bodylinelenlimit = getenv("MBLAZE_RELAXED_MIME") ? 998 : 78;
int c;
int l = -1;
@@ -554,7 +555,7 @@ check()
}
if (bitlow == 0 && bithigh == 0 &&
- maxheadlinelen < 998 && maxbodylinelen <= 78 &&
+ maxheadlinelen < 998 && maxbodylinelen <= bodylinelenlimit &&
l == '\n')
return 0;
else
diff --git a/t/1000-mmime.t b/t/1000-mmime.t
index 6d4c40c..ca9dd82 100755
--- a/t/1000-mmime.t
+++ b/t/1000-mmime.t
@@ -2,7 +2,7 @@
cd ${0%/*}
. ./lib.sh
-plan 17
+plan 19
cat <<EOF >tmp
References: <aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@a> <bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb@b> <ccccccccccccccccccccccccccccccc@c>
@@ -124,3 +124,13 @@ Subject: inclusion without further content
EOF
check 'no empty parts are generated after inclusion lines' '! mmime <tmp2 | mshow -t - | grep -q size=0'
+
+cat <<EOF >tmp2
+Subject: Strict mode
+
+Body with lines longer than 78 characters
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+EOF
+
+check 'body lines longer than 78 characters needs MIME formatting' '! mmime -c <tmp2'
+check 'MBLAZE_RELAXED_MIME allows body lines longer than 78 characters' 'MBLAZE_RELAXED_MIME= mmime -c <tmp2'