summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2016-11-23 00:00:30 +0100
committerHolger Levsen <holger@layer-acht.org>2016-11-23 00:00:30 +0100
commit5fce99cb4e263f93655f17f4062a3379b7be1daf (patch)
tree2be6762ac14cdbc960951d0b72746a84e8f79e03
parent9b0bd74bf60219f98531425d7ebe4a9af0a315d8 (diff)
downloadjenkins.debian.net-5fce99cb4e263f93655f17f4062a3379b7be1daf.tar.xz
YOLO: try to parse quoted-printable continuation lines
Signed-off-by: Holger Levsen <holger@layer-acht.org>
-rwxr-xr-xbin/email2irc.sh34
1 files changed, 24 insertions, 10 deletions
diff --git a/bin/email2irc.sh b/bin/email2irc.sh
index 5909b509..450ca0d0 100755
--- a/bin/email2irc.sh
+++ b/bin/email2irc.sh
@@ -23,6 +23,7 @@ DEBUG=false
HEADER=true
VALID_MAIL=false
MY_LINE=""
+MY_2ND_LINE=""
while read -r line ; do
if [ "$HEADER" = "true" ] ; then
# check if email header ends
@@ -58,18 +59,31 @@ while read -r line ; do
if [ "$HEADER" = "false" ] && [ -z "$MY_LINE" ] ; then
MY_LINE=$line
debug123 "#1" MY_LINE $MY_LINE
- # if this is a multipart email it comes from the email extension plugin
- if [ "${line:0:7}" = "------=" ] || [ "${line:0:9}" = "Content-T" ] ; then
- debug123 "#2" line $line
- MY_LINE=""
+ if [ ! -z "$MY_2ND_LINE" ] ; then
+ # if this is a multipart email it comes from the email extension plugin
+ if [ "${line:0:7}" = "------=" ] || [ "${line:0:9}" = "Content-T" ] ; then
+ debug123 "#2" line $line
+ MY_LINE=""
+ else
+ debug123 "#3" line $line
+ MY_LINE=$(echo $line | tr -d \< | tr -d \> | cut -d " " -f1-2)
+ debug123 "#4" MY_LINE $MY_LINE
+ fi
+ # deal with quoted-printable continuation lines: 1st line/time
+ # if $MY_LINE ends with '=', then append the next line to $MY_LINE,
+ # changing the '=' to a single space.
+ if [[ $MY_LINE =~ ^(.*)=$ ]] ; then
+ MY_2ND_LINE=$MY_LINE
+ MY_LINE=""
+ fi
else
- debug123 "#3" line $line
- MY_LINE=$(echo $line | tr -d \< | tr -d \> | cut -d " " -f1-2)
- debug123 "#4" MY_LINE $MY_LINE
+ # deal with quoted-printable continuation lines: 2nd line/time
+ # if $MY_LINE ends with '=', then append the next line to $MY_LINE,
+ # TODO: changing the '=' to a single space.
+ MY_LINE="$MY_LINE $MY_2ND_LINE"
+ debug123 "#5" MY_LINE $MY_LINE
+ debug123 "#6" MY_2ND_LINE $MY_2ND_LINE
fi
- # TODO: deal with quoted-printable continuation lines:
- # if $MY_LINE ends with '=', then append the next line to $MY_LINE,
- # changing the '=' to a single space.
fi
done
# check that it's a valid job