[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.1-545-g0b00e7a2d9

? sunnavy sunnavy at bestpractical.com
Thu Jun 24 18:59:38 EDT 2021


The branch, 5.0-trunk has been updated
       via  0b00e7a2d94627bd14af54732502691517a1cdb7 (commit)
       via  19327d95ba005ae62e46ab2934fa56def0803e34 (commit)
      from  b07aeff2f88c074ca4ca074fed4a56e9592856eb (commit)

Summary of changes:
 lib/RT/Config.pm        |  1 +
 lib/RT/Interface/Web.pm | 12 ++++++++++++
 2 files changed, 13 insertions(+)

- Log -----------------------------------------------------------------
commit 19327d95ba005ae62e46ab2934fa56def0803e34
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Jun 24 16:37:58 2021 -0400

    Reload scrubber rules when web config changes are made
    
    RT's HTML scrubber loads its rules in the constructor and
    the scrubber object is persistent via the 'state' pragma.
    Some RT config options can change the rules, so if config
    is changed, we need to reload.
    
    state variables can only be modified in the scope where
    they are declared, so create a flag to tell us to reload
    when necessary.
    
    Before this change, updating the ShowRemoteImages config
    option would not take effect immediately in the running
    RT.

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index c03bc2fffd..a8e4539c65 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -2742,6 +2742,7 @@ sub RefreshConfigFromDatabase {
     my $needs_update = RT->System->ConfigCacheNeedsUpdate;
     if ($needs_update > $database_config_cache_time) {
         $self->LoadConfigFromDatabase();
+        $HTML::Mason::Commands::ReloadScrubber = 1;
         $database_config_cache_time = $needs_update;
     }
 }
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index d9d6bd7a6c..aebb08a098 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -4678,8 +4678,20 @@ Removes unsafe and undesired HTML from the passed content
 
 =cut
 
+# The scrubber loads its rules in the constructor and some RT
+# config options can change the rules. If config is changed,
+# this flag tells us to reload the state-ful scrubber.
+
+our $ReloadScrubber;
+
 sub ScrubHTML {
     state $scrubber = RT::Interface::Web::Scrubber->new;
+
+    if ( $HTML::Mason::Commands::ReloadScrubber ) {
+        $scrubber = RT::Interface::Web::Scrubber->new;
+        $HTML::Mason::Commands::ReloadScrubber = 0;
+    }
+
     return $scrubber->scrub(@_);
 }
 

commit 0b00e7a2d94627bd14af54732502691517a1cdb7
Merge: b07aeff2f8 19327d95ba
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jun 25 05:17:26 2021 +0800

    Merge branch '5.0/reload-scrubber-on-config-change' into 5.0-trunk


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


More information about the rt-commit mailing list