Subject: | [Patch] New configuration option: CommandByMailStripOut |
MIME-Version: | 1.0 |
X-Mailer: | MIME-tools 5.418 (Entity 5.418) |
Charset: | utf8 |
X-RT-Original-Encoding: | utf-8 |
Content-Type: | multipart/mixed; boundary="----------=_1198235829-25646-4" |
Content-Length: | 0 |
Content-Type: | text/plain |
Content-Disposition: | inline |
Content-Transfer-Encoding: | binary |
Content-Length: | 132 |
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 |
MIME-Version: | 1.0 |
Content-Type: | multipart/mixed; boundary="----------=_1198235828-25646-3" |
X-Mailer: | MIME-tools 5.418 (Entity 5.418) |
Charset: | utf8 |
Content-Length: | 0 |
Content-Type: | text/plain |
Content-Disposition: | inline |
Content-Transfer-Encoding: | binary |
X-RT-Original-Encoding: | iso-8859-1 |
Content-Length: | 0 |
Content-Type: | text/x-diff; name="RT-Extension-CommandByMail-command-strip-out.diff" |
Content-Disposition: | inline; filename="RT-Extension-CommandByMail-command-strip-out.diff" |
Content-Transfer-Encoding: | binary |
Content-Length: | 1386 |
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 ) {