summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2023-07-17 09:59:59 +0200
committertv <tv@krebsco.de>2023-08-01 11:09:29 +0200
commit54db2a56a69b2d6ce894f879568a94003472cbf7 (patch)
tree904810f3df571ccb0c508cd3663f6cd1a3d2a3a1
parenteb0d785c1be0ef31d38b95b9a53b79081126eea4 (diff)
parts: base64 encode text with too long linesfeature/parts
-rwxr-xr-xscripts/parts19
1 files changed, 15 insertions, 4 deletions
diff --git a/scripts/parts b/scripts/parts
index ae73c2f..6449a6e 100755
--- a/scripts/parts
+++ b/scripts/parts
@@ -66,10 +66,21 @@ add_part() {(
contentType="$(file -Lib "$filepath"); name=$filename"
case $contentType in
text/plain|text/plain\;*)
- contentTransferEncoding=8bit
- content() {
- cat "$filepath"
- }
+ max_length=$(awk '
+ length > max_length { max_length = length }
+ END { print max_length }
+ ')
+ if test "$max_length" -le 998; then
+ contentTransferEncoding=8bit
+ content() {
+ cat "$filepath"
+ }
+ else
+ contentTransferEncoding=base64
+ content() {
+ base64 "$filepath"
+ }
+ fi
;;
*)
contentTransferEncoding=base64