summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Dujava <jonas.dujava@gmail.com>2024-09-02 12:24:34 +0200
committerJonas Dujava <jonas.dujava@gmail.com>2024-09-02 12:50:37 +0200
commit43eceb55364dc0e6b1bf35ff461f7c2554ff8e8e (patch)
treee1715fc445c8d1da86e14a4d84e16e8aed5a8e2b
parent7129fa0597f3f365459de51c560c9d5c68bbd707 (diff)
Fix notifications for mails with multiline subject
Signed-off-by: Jonas Dujava <jonas.dujava@gmail.com>
-rwxr-xr-xbin/mailsync7
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/mailsync b/bin/mailsync
index cbd36ff..2cf6619 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -70,9 +70,10 @@ syncandnotify() {
echo "$newcount new mail for $2."
[ -z "$MAILSYNC_MUTE" ] &&
for file in $new; do
- # Extract and decode subject and sender from mail.
- subject="$(sed -n "/^Subject:/ s|Subject: *|| p" "$file" |
- perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')"
+ # Extract and decode subject and sender from mail.
+ subject=$(awk '/^Subject: / && ++n == 1,/^.*: / && ++i == 2' "$file" | head -n-1 |
+ perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' |
+ sed 's/^Subject: //' | tr -d '\n\t')
from="$(sed -n "/^From:/ s|From: *|| p" "$file" |
perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')"
from="${from% *}" ; from="${from%\"}" ; from="${from#\"}"