[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.0-112-g9f2b968045

? sunnavy sunnavy at bestpractical.com
Tue Nov 10 13:51:15 EST 2020


The branch, 5.0-trunk has been updated
       via  9f2b9680451fc5b0d72e958a41987b161f9ef1fa (commit)
       via  6fb87604f14811acf9e5d75c41eb20c9cf4cb9c2 (commit)
       via  07c260d62fb0411085faa02b9027f2929012b698 (commit)
      from  26f984dc52b96e4cb84770712d9968d6821ee43a (commit)

Summary of changes:
 sbin/rt-munge-attachments.in | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit 07c260d62fb0411085faa02b9027f2929012b698
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..9184bd1857 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 6fb87604f14811acf9e5d75c41eb20c9cf4cb9c2
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 9184bd1857..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', '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

commit 9f2b9680451fc5b0d72e958a41987b161f9ef1fa
Merge: 26f984dc52 6fb87604f1
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 11 02:41:55 2020 +0800

    Merge branch '5.0/additional-munge-attachments-features' into 5.0-trunk


-----------------------------------------------------------------------


More information about the rt-commit mailing list