[Rt-commit] rt branch, 5.0/additional-munge-attachments-features, updated. rt-5.0.0-5-gf8b3210e45
Craig Kaiser
craig at bestpractical.com
Mon Aug 17 11:46:38 EDT 2020
The branch, 5.0/additional-munge-attachments-features has been updated
via f8b3210e4509289fec55cf5755299e5e0ee2fa7c (commit)
from b33f90ae96b970502bbb0e619e9affd22e20a970 (commit)
Summary of changes:
sbin/rt-munge-attachments.in | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
- Log -----------------------------------------------------------------
commit f8b3210e4509289fec55cf5755299e5e0ee2fa7c
Author: craig kaiser <craig at bestpractical.com>
Date: Mon Aug 17 11:29:42 2020 -0400
Allow specifying of transactions for rt-munge-attachments to munge
diff --git a/sbin/rt-munge-attachments.in b/sbin/rt-munge-attachments.in
index 67ffd2c697..eb89ed3557 100644
--- a/sbin/rt-munge-attachments.in
+++ b/sbin/rt-munge-attachments.in
@@ -70,7 +70,7 @@ BEGIN { # BEGIN RT CMD BOILERPLATE
# Read in the options
my %opts;
use Getopt::Long;
-GetOptions( \%opts, "help|h", "search=s", "replacement=s", 'tickets=s', 'no-headers', 'no-content' );
+GetOptions( \%opts, "help|h", "search=s", "replacement=s", 'tickets=s', 'transactions=s', 'no-headers', 'no-content' );
if ( $opts{'help'} || !$opts{'search'} ) {
require Pod::Usage;
@@ -86,11 +86,10 @@ my $content = $opts{'no-content'} ? 0 : 1;
my $search = $opts{'search'};
-my $attachments;
+my $attachments = RT::Attachments->new( RT->SystemUser );
if ( $opts{tickets} ) {
my @tickets = split /\s*,\s*/, $opts{tickets};
- $attachments = RT::Attachments->new( RT->SystemUser );
my $txn_alias = $attachments->TransactionAlias;
$attachments->Limit(
ALIAS => $txn_alias,
@@ -110,8 +109,15 @@ if ( $opts{tickets} ) {
OPERATOR => 'IN',
);
}
-else {
- $attachments = RT::Attachments->new( RT->SystemUser );
+
+if ( $opts{'transactions'} ) {
+ my @transactions = split /\s*,\s*/, $opts{'transactions'};
+
+ $attachments->Limit(
+ FIELD => 'TransactionId',
+ VALUE => \@transactions,
+ OPERATOR => 'IN',
+ );
}
my ( $ret, $msg ) = $attachments->ReplaceAttachments(
@@ -166,11 +172,16 @@ Provide a string to replace the value matched by the search.
=item --tickets=1,2,3
-Limit attachments to the specified tickets. Note that if tickets are not
-specified, RT will pre-filter attachments by the search string use SQL,
+Limit attachments to the specified tickets. Note that if tickets or transactions
+are not specified, RT will pre-filter attachments by the search string use SQL,
which might bypass attachments of which contents are encoded(like
base64). Use this option to prevent the pre-filter behavior.
+=item --transactions=123,456,7
+
+Limit attachments to the specified transactions. If specified the default pre-filtering
+will be prevented. This option takes precedence over the --tickets flag.
+
=item --no-headers
BY default headers are also munged, to disable munging of headers set the
-----------------------------------------------------------------------
More information about the rt-commit
mailing list