From 5a8154024ab3aadf6c374712a1cad4719f9d0caa Mon Sep 17 00:00:00 2001 From: alech Date: Thu, 2 Apr 2009 15:46:48 +0000 Subject: [PATCH] RT notifier: parse templates without header correctly git-svn-id: https://openxpki.svn.sourceforge.net/svnroot/openxpki@1438 95d9436f-6502-0410-902c-bd9569d1a17e --- .../core/trunk/OpenXPKI/Server/Notification/RT.pm | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/trunk/perl-modules/core/trunk/OpenXPKI/Server/Notification/RT.pm b/trunk/perl-modules/core/trunk/OpenXPKI/Server/Notification/RT.pm index b5cb3436..d6cf7b58 100644 --- a/trunk/perl-modules/core/trunk/OpenXPKI/Server/Notification/RT.pm +++ b/trunk/perl-modules/core/trunk/OpenXPKI/Server/Notification/RT.pm @@ -333,25 +333,32 @@ sub __parse_content { my @content = split(/\n/, $content); my @cc = (); my @bcc = (); - my $end_of_header_index = 0; - PARSE_HEADER: - for (my $i = 0; $i < scalar @content; $i++) { - my $line = $content[$i]; - if ($line eq '') { - $end_of_header_index = $i; - last PARSE_HEADER; - } - if ($line =~ m{ \A Cc: (.*) \z}xms) { - push @cc, $1; + my $body = ''; + if ($content[0] =~ /:/) { + # the content contains a header, parse it + my $end_of_header_index = 0; + PARSE_HEADER: + for (my $i = 0; $i < scalar @content; $i++) { + my $line = $content[$i]; + if ($line eq '') { + $end_of_header_index = $i; + last PARSE_HEADER; + } + if ($line =~ m{ \A Cc: (.*) \z}xms) { + push @cc, $1; + } + if ($line =~ m{ \A Bcc: (.*) \z}xms) { + push @bcc, $1; + } } - if ($line =~ m{ \A Bcc: (.*) \z}xms) { - push @bcc, $1; + # create body + for (my $i = $end_of_header_index; $i < scalar @content; $i++) { + $body .= $content[$i] . "\n"; } } - # create body - my $body = ''; - for (my $i = $end_of_header_index; $i < scalar @content; $i++) { - $body .= $content[$i] . "\n"; + else { + # the complete content is the body. + $body = $content; } ##! 1: 'end' return (\@cc, \@bcc, $body); -- 2.11.4.GIT