summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-03-21 10:04:56 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-03-21 10:04:56 (GMT)
commitef0333f5da300072a87d6572443e67dcea2c6da7 (patch)
tree880c17b404268c47413c551052ab523e660f460e /libexec
parent232680a8beeb6a3af38259b4e4467a34971356cf (diff)
downloadsite-ef0333f5da300072a87d6572443e67dcea2c6da7.tar.gz
filter-github-emails: Strip leading blank lines
Email::MIME sometimes prepends an empty line when returning an email as string :-/
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/filter-github-emails16
1 files changed, 14 insertions, 2 deletions
diff --git a/libexec/filter-github-emails b/libexec/filter-github-emails
index 5abf1b0..85ec1a3 100755
--- a/libexec/filter-github-emails
+++ b/libexec/filter-github-emails
@@ -140,6 +140,18 @@ sub rewrap {
140} 140}
141 141
142# 142#
143# Write the email to STDOUT.
144#
145sub print_email {
146 my $email = shift;
147 my $text = $email->as_string;
148
149 # Email::MIME sometimes prepends an empty line :-/
150 $text =~ s/^[\r\n]+//;
151 print $email->as_string;
152}
153
154#
143# Look up MIME parts. 155# Look up MIME parts.
144# 156#
145 157
@@ -260,7 +272,7 @@ sub handle_github_mail {
260 $email->header_obj_set(edit_header($email->header_obj, 272 $email->header_obj_set(edit_header($email->header_obj,
261 COMMENTS_TO, 'GitHub comment')); 273 COMMENTS_TO, 'GitHub comment'));
262 } 274 }
263 print $email->as_string; 275 print_email($email);
264} 276}
265 277
266sub handle_non_github_mail { 278sub handle_non_github_mail {
@@ -268,7 +280,7 @@ sub handle_non_github_mail {
268 280
269 notice('Received a non-GitHub message'); 281 notice('Received a non-GitHub message');
270 # Just spit out the email as-is. 282 # Just spit out the email as-is.
271 print $email->as_string; 283 print_email($email);
272} 284}
273 285
274# 286#