Bug 22007: Also handle Price and HtmlTags
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 14 Dec 2018 20:34:52 +0000 (17:34 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 2 Jan 2019 20:42:19 +0000 (20:42 +0000)
Those 2 filters should return safe output as well

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

t/lib/QA/TemplateFilters.pm
t/template_filters.t

index c4ec77d..0fce6da 100644 (file)
@@ -134,6 +134,8 @@ sub process_tt_block {
         # Already escaped with a special filter
         # We could escape it but should be safe
         or $tt_block =~ m{\s?\|\s?\$KohaDates[^\|]*$}
+        or $tt_block =~ m{\s?\|\s?\$Price[^\|]*$}
+        or $tt_block =~ m{\s?\|\s?\$HtmlTags[^\|]*$}
 
         # Already escaped correctly with raw
         or $tt_block =~ m{\|\s?\$raw}
@@ -166,6 +168,8 @@ sub process_tt_block {
       : q| |;
 
     if (   $tt_block =~ m{\s?\|\s?\$KohaDates[^\|]*\|.*$}
+        or $tt_block =~ m{\s?\|\s?\$Price[^\|]*\|.*$}
+        or $tt_block =~ m{\s?\|\s?\$HtmlTags[^\|]*\|.*$}
     ) {
         $tt_block =~
           s/\s*\|\s*(uri|url|html)\s*$//;    # Could be another filter...
index e469835..fb30229 100644 (file)
@@ -261,13 +261,15 @@ INPUT
     is_deeply( \@missing_filters, [], 'html_entity is a valid filter for href' );
 };
 
-subtest 'Do not escape KohaDates output' => sub {
+subtest 'Do not escape KohaDates|Prices|HtmlTags output' => sub {
     plan tests => 2;
     my $input = <<INPUT;
 [% var | \$KohaDates %]
 [% var | \$KohaDates with_hours => 1 %]
 [% var | \$KohaDates | html %]
 [% var | \$KohaDates with_hours => 1 | html %]
+[% var | \$Price %]
+[% var | \$HtmlTags %]
 INPUT
 
     my $expected = <<EXPECTED;
@@ -275,6 +277,8 @@ INPUT
 [% var | \$KohaDates with_hours => 1 %]
 [% var | \$KohaDates %]
 [% var | \$KohaDates with_hours => 1 %]
+[% var | \$Price %]
+[% var | \$HtmlTags %]
 EXPECTED
 
     my $new_content = t::lib::QA::TemplateFilters::fix_filters($input);