[Rt-commit] rt branch, 5.0/additional-munge-attachments-features, created. rt-5.0.0-5-gbdbfb7fcb0
Craig Kaiser
craig at bestpractical.com
Tue Nov 10 11:55:59 EST 2020
The branch, 5.0/additional-munge-attachments-features has been created
at bdbfb7fcb00aaf83f0eb5309f84857cdac179099 (commit)
- Log -----------------------------------------------------------------
commit a377355472a120ff0d83c890ce446243d79b5134
Author: craig kaiser <craig at bestpractical.com>
Date: Wed Aug 12 15:01:09 2020 -0400
Allow header and content munging to be disabled by flags
diff --git a/sbin/rt-munge-attachments.in b/sbin/rt-munge-attachments.in
index a0869441e4..b9f70bd26f 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', 'skip-headers', 'skip-content' );
if ( $opts{'help'} || !$opts{'search'} ) {
require Pod::Usage;
@@ -81,6 +81,8 @@ 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'};
@@ -113,6 +115,8 @@ else {
}
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 ) : (),
@@ -167,4 +171,14 @@ 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 --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
commit bdbfb7fcb00aaf83f0eb5309f84857cdac179099
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 b9f70bd26f..e4aa19b587 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', 'skip-headers', 'skip-content' );
+GetOptions( \%opts, "help|h", "search=s", "replacement=s", 'tickets=s', 'transactions=s', 'skip-headers', 'skip-content' );
if ( $opts{'help'} || !$opts{'search'} ) {
require Pod::Usage;
@@ -86,11 +86,10 @@ 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,
@@ -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(
@@ -119,7 +125,7 @@ my ( $ret, $msg ) = $attachments->ReplaceAttachments(
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";
@@ -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 can work alongside the --tickets flag.
+
=item --skip-headers
BY default headers are also munged, to disable munging of headers set the
-----------------------------------------------------------------------
More information about the rt-commit
mailing list