[Bps-public-commit] rt-extension-rewritesubject branch master updated. f96314f7edf3825e825f798022c5910f6ba244e4

BPS Git Server git at git.bestpractical.com
Fri Jun 30 14:24:10 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-rewritesubject".

The branch, master has been updated
       via  f96314f7edf3825e825f798022c5910f6ba244e4 (commit)
      from  fbb78c74d60104fa78247781c6fa98ee603ced32 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f96314f7edf3825e825f798022c5910f6ba244e4
Author: Brian Conry <bconry at bestpractical.com>
Date:   Fri Jun 30 09:18:45 2023 -0500

    Sort patterns/keys from config
    
    The initial implementation didn't sort the kyes of the config hashes,
    which are the patterns that it tests against various elements.
    
    This adds sorts so that the extension will behave deterministically even
    if given a configuration with overlapping criteria.

diff --git a/lib/RT/Interface/Email/RewriteSubject.pm b/lib/RT/Interface/Email/RewriteSubject.pm
index ac00eda..78e6cb5 100644
--- a/lib/RT/Interface/Email/RewriteSubject.pm
+++ b/lib/RT/Interface/Email/RewriteSubject.pm
@@ -124,7 +124,7 @@ sub BeforeDecode {
 
     return unless $subject and $body;
 
-    foreach my $email_pattern (keys %$config) {
+    foreach my $email_pattern (sort keys %$config) {
         my %capture_info;
 
         if ($Address =~ $email_pattern) {
@@ -132,14 +132,14 @@ sub BeforeDecode {
 
             my $email_config = $config->{$email_pattern};
 
-            foreach my $subject_pattern (keys %$email_config) {
+            foreach my $subject_pattern (sort keys %$email_config) {
                 if ($subject =~ $subject_pattern) {
                     $capture_info{subject} = { positional => [ @{^CAPTURE} ], named => { %+ } };
 
                     my $subject_config = $email_config->{$subject_pattern};
 
 BODY_IDENTITY_PATTERN:
-                    foreach my $body_identity_pattern (keys %$subject_config) {
+                    foreach my $body_identity_pattern (sort keys %$subject_config) {
                         if ($body =~ $body_identity_pattern) {
                             $capture_info{body} = [];
                             push @{ $capture_info{body} }, { positional => [ @{^CAPTURE} ], named => { %+ } };
@@ -173,7 +173,7 @@ BODY_IDENTITY_PATTERN:
                                 $new_subject = RT->SystemUser->loc( $subject_proto, @all_positionals );
                             }
 
-                            if ($new_subject) {
+                            if (defined $new_subject) {
                                 $head->set('Subject', Encode::encode( "UTF-8", $new_subject ));
                                 return;
                             }
-----------------------------------------------------------------------

Summary of changes:
 lib/RT/Interface/Email/RewriteSubject.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
rt-extension-rewritesubject


More information about the Bps-public-commit mailing list