Subject: | [Patch] New configuration option: CommandByMailStripOut |
Attached patch adds a new configuration option CommandByMailStripOut
which allows commands to be stripped out from the mail content.
Subject: | RT-Extension-CommandByMail-command-strip-out.diff |
diff -ur RT-Extension-CommandByMail-0.05/lib/RT/Interface/Email/Filter/TakeAction.pm RT-Extension-CommandByMail/lib/RT/Interface/Email/Filter/TakeAction.pm
===================================================================
--- RT-Extension-CommandByMail-0.05/lib/RT/Interface/Email/Filter/TakeAction.pm (revision 826)
+++ RT-Extension-CommandByMail/lib/RT/Interface/Email/Filter/TakeAction.pm (revision 1105)
@@ -172,9 +172,11 @@
}
my @content;
+ my $body;
my @parts = $args{'Message'}->parts_DFS;
+
foreach my $part (@parts) {
- my $body = $part->bodyhandle or next;
+ $body = $part->bodyhandle or next;
#if it looks like it has pseudoheaders, that's our content
if ( $body->as_string =~ /^(?:\S+):/m ) {
@@ -205,6 +207,23 @@
}
}
+ # Strip out commands from content if configuration says so
+ if ($RT::CommandByMailStripOut) {
+ my @content = $body->as_lines;
+ my $io = $body->open("w") or die "Cannot open body";
+
+ my $body_top = 1;
+ foreach my $line (@content) {
+ # Strip out commands only at the top
+ next if ($body_top && $line =~ /^(?:(\S+)\s*?:\s*?(.*)\s*?|)$/);
+ $body_top = 0;
+
+ $io->print($line);
+ }
+
+ $io->close() or die "Cannot close body";
+ }
+
my %results;
foreach my $cmd ( keys %cmds ) {