From 1ef675e5c2a679beba23cbf6567a0b4b1a3b4211 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 6 Nov 2009 15:40:51 +0100 Subject: [PATCH] taskd/mail.sh: Limit mail size to 256kb. --- taskd/mail.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/taskd/mail.sh b/taskd/mail.sh index 6d7ccfa..e3e649c 100755 --- a/taskd/mail.sh +++ b/taskd/mail.sh @@ -19,6 +19,7 @@ # * Unsubscribe instructions in email footer. # * Default showrev includes gitweb link. # * Nicer subject line. +# * Limit mail size to 256kb. # ================= # # This hook is stored in the contrib/hooks directory. Your distribution @@ -661,6 +662,20 @@ show_new_revisions() } +size_limit() +{ + size=0 + while IFS= read line; do + size=$((size+${#line})) + if [ $size -gt $1 ]; then + echo "...e-mail trimmed, has been too large." + break + fi + echo "$line" + done +} + + send_mail() { if [ -n "$envelopesender" ]; then @@ -720,10 +735,10 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then # Output to the terminal in command line mode - if someone wanted to # resend an email; they could redirect the output to sendmail # themselves - generate_email $2 $3 $1 | send_mail + generate_email $2 $3 $1 | size_limit $((256*1024)) | send_mail else while read oldrev newrev refname do - generate_email $oldrev $newrev $refname | send_mail + generate_email $oldrev $newrev $refname | size_limit $((256*1024)) | send_mail done fi -- 2.11.4.GIT