Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bestpractical/rt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorsunnavy <sunnavy@bestpractical.com>2020-11-10 21:41:55 +0300
committersunnavy <sunnavy@bestpractical.com>2020-11-10 21:41:55 +0300
commit9f2b9680451fc5b0d72e958a41987b161f9ef1fa (patch)
treef688b75b71eac70433e6344c34b3e2d6ff8c4c52 /sbin
parent26f984dc52b96e4cb84770712d9968d6821ee43a (diff)
parent6fb87604f14811acf9e5d75c41eb20c9cf4cb9c2 (diff)
Merge branch '5.0/additional-munge-attachments-features' into 5.0-trunk
Diffstat (limited to 'sbin')
-rw-r--r--sbin/rt-munge-attachments.in41
1 files changed, 33 insertions, 8 deletions
diff --git a/sbin/rt-munge-attachments.in b/sbin/rt-munge-attachments.in
index a0869441e4..9b5b30c57c 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' );
+GetOptions( \%opts, "help|h", "search=s", "replacement=s", 'tickets=s', 'transactions=s', 'skip-headers', 'skip-content' );
if ( $opts{'help'} || !$opts{'search'} ) {
require Pod::Usage;
@@ -81,14 +81,15 @@ if ( $opts{'help'} || !$opts{'search'} ) {
use RT -init;
my $replacement = $opts{'replacement'} || '';
+my $headers = $opts{'skip-headers'} ? 0 : 1;
+my $content = $opts{'skip-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,
@@ -108,14 +109,23 @@ 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(
+ Headers => $headers,
+ Content => $content,
Search => Encode::decode( 'UTF-8', $search ),
Replacement => Encode::decode( 'UTF-8', $replacement ),
- $opts{tickets} ? ( FilterBySearchString => 0 ) : (),
+ $opts{tickets} || $opts{transactions} ? ( FilterBySearchString => 0 ) : (),
);
print STDERR $msg . "\n";
@@ -162,9 +172,24 @@ 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 can work alongside the --tickets flag.
+
+=item --skip-headers
+
+By default headers are also munged, to disable munging of headers set the
+--skip-headers flag.
+
+=item --skip-content
+
+By default transaction content is munged, to disable munging of content set the
+--skip-content flag.
+
=back