[Rt-commit] rt branch 5.0/format-strings-dont-need-html-structure-checked created. rt-5.0.2-258-gb2cc974387

BPS Git Server git at git.bestpractical.com
Tue Jun 7 20:46:56 UTC 2022


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".

The branch, 5.0/format-strings-dont-need-html-structure-checked has been created
        at  b2cc974387b4d2efc034c283f22aed8e2fbe6fd2 (commit)

- Log -----------------------------------------------------------------
commit b2cc974387b4d2efc034c283f22aed8e2fbe6fd2
Author: Brian Conry <bconry at bestpractical.com>
Date:   Tue Jun 7 15:30:23 2022 -0500

    Exempt some format strings from HTML::Gumbo
    
    HTML::Gumbo undoes some of the escaping applied by EscapeHTML that is
    necessary for properly displaying apostrophes in column titles.
    
    This adds a flag to the scrubbing methods to skip the structure check in
    cases, such as format strings, where we do not ever expect to have htat
    type of issue, and where side-effects of doing that check cause
    problems.
    
    There may be other places that format strings are processed that should
    also be updated.

diff --git a/lib/RT/Interface/Web/Scrubber.pm b/lib/RT/Interface/Web/Scrubber.pm
index f44f7784eb..e8cef2ba87 100644
--- a/lib/RT/Interface/Web/Scrubber.pm
+++ b/lib/RT/Interface/Web/Scrubber.pm
@@ -221,10 +221,13 @@ L<HTML::Scrubber/scrub>.
 sub scrub {
     my $self = shift;
     my $Content = shift // '';
+    my $skip_structure_check = shift // 0;
 
-    # First pass through HTML::Gumbo to balance the tags
-    eval { $Content = $self->gumbo->parse( $Content ); chomp $Content };
-    warn "HTML::Gumbo pre-parse failed: $@" if $@;
+    unless ( $skip_structure_check ) {
+        # First pass through HTML::Gumbo to balance the tags
+        eval { $Content = $self->gumbo->parse( $Content ); chomp $Content };
+        warn "HTML::Gumbo pre-parse failed: $@" if $@;
+    }
 
     return $self->SUPER::scrub($Content);
 }
diff --git a/share/html/Elements/CollectionList b/share/html/Elements/CollectionList
index 95410282df..43eccb001c 100644
--- a/share/html/Elements/CollectionList
+++ b/share/html/Elements/CollectionList
@@ -104,8 +104,8 @@ $Collection->GotoPage( $Page - 1 ); # SB uses page 0 as the first page
 $DisplayFormat ||= $Format;
 
 # Scrub the html of the format string to remove any potential nasties.
-$Format = $m->comp('/Elements/ScrubHTML', Content => $Format);
-$DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $DisplayFormat);
+$Format = $m->comp('/Elements/ScrubHTML', Content => $Format, SkipStructureCheck => 1);
+$DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $DisplayFormat, SkipStructureCheck => 1);
 
 my @Format = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $DisplayFormat);
 
diff --git a/share/html/Elements/ScrubHTML b/share/html/Elements/ScrubHTML
index 119adc5f74..996166a0e5 100644
--- a/share/html/Elements/ScrubHTML
+++ b/share/html/Elements/ScrubHTML
@@ -46,8 +46,9 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <%init>
-return ScrubHTML($Content);
+return ScrubHTML($Content, $SkipStructureCheck);
 </%init>
 <%args>
 $Content => undef
+$SkipStructureCheck => undef
 </%args>

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list