Bugzilla – Attachment 83287 Details for
Bug 22007
KohaDates output does not need to be html filtered
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22007: Handle safe filtered output (KohaDates)
Bug-22007-Handle-safe-filtered-output-KohaDates.patch (text/plain), 3.50 KB, created by
Owen Leonard
on 2018-12-17 14:18:09 UTC
(
hide
)
Description:
Bug 22007: Handle safe filtered output (KohaDates)
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2018-12-17 14:18:09 UTC
Size:
3.50 KB
patch
obsolete
>From 08fc21a04bf093cd141e44bd7f034ec962da9194 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 14 Dec 2018 17:29:18 -0300 >Subject: [PATCH] Bug 22007: Handle safe filtered output (KohaDates) > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > t/lib/QA/TemplateFilters.pm | 20 +++++++++++++++++--- > t/template_filters.t | 41 ++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 57 insertions(+), 4 deletions(-) > >diff --git a/t/lib/QA/TemplateFilters.pm b/t/lib/QA/TemplateFilters.pm >index 467010e..c4ec77d 100644 >--- a/t/lib/QA/TemplateFilters.pm >+++ b/t/lib/QA/TemplateFilters.pm >@@ -133,14 +133,13 @@ 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\s?$} >- or $tt_block =~ m{\s?\|\s?\$Price\s?$} >+ or $tt_block =~ m{\s?\|\s?\$KohaDates[^\|]*$} > > # Already escaped correctly with raw > or $tt_block =~ m{\|\s?\$raw} > > # Assignment, maybe we should require to use SET (?) >- or $tt_block =~ m{=} >+ or ( $tt_block =~ m{=} and not $tt_block =~ m{\s\|\s} ) > > # Already has url or uri filter > or $tt_block =~ m{\|\s?ur(l|i)} >@@ -166,6 +165,21 @@ sub process_tt_block { > : q| | > : q| |; > >+ if ( $tt_block =~ m{\s?\|\s?\$KohaDates[^\|]*\|.*$} >+ ) { >+ $tt_block =~ >+ s/\s*\|\s*(uri|url|html)\s*$//; # Could be another filter... >+ $line =~ s{ >+ \[% >+ \s*$pre_chomp\s* >+ \Q$tt_block\E\s*\|\s*(uri|url|html) >+ \s*$post_chomp\s* >+ %\] >+ }{[%$pre_chomp$tt_block$post_chomp%]}xms; >+ >+ return ( $line, 'extra_filter_not_needed' ); >+ } >+ > if ( > # Use the uri filter is needed > # If html filtered or not filtered >diff --git a/t/template_filters.t b/t/template_filters.t >index be638e1..e469835 100644 >--- a/t/template_filters.t >+++ b/t/template_filters.t >@@ -16,7 +16,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 5; >+use Test::More tests => 6; > use t::lib::QA::TemplateFilters; > > subtest 'Asset must use raw' => sub { >@@ -260,3 +260,42 @@ INPUT > @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input); > is_deeply( \@missing_filters, [], 'html_entity is a valid filter for href' ); > }; >+ >+subtest 'Do not escape KohaDates output' => sub { >+ plan tests => 2; >+ my $input = <<INPUT; >+[% var | \$KohaDates %] >+[% var | \$KohaDates with_hours => 1 %] >+[% var | \$KohaDates | html %] >+[% var | \$KohaDates with_hours => 1 | html %] >+INPUT >+ >+ my $expected = <<EXPECTED; >+[% var | \$KohaDates %] >+[% var | \$KohaDates with_hours => 1 %] >+[% var | \$KohaDates %] >+[% var | \$KohaDates with_hours => 1 %] >+EXPECTED >+ >+ my $new_content = t::lib::QA::TemplateFilters::fix_filters($input); >+ is( $new_content . "\n", $expected, ); >+ >+ >+ my @missing_filters = t::lib::QA::TemplateFilters::missing_filters($input); >+ is_deeply( >+ \@missing_filters, >+ [ >+ { >+ error => "extra_filter_not_needed", >+ line => "[% var | \$KohaDates | html %]", >+ line_number => 3, >+ }, >+ { >+ error => "extra_filter_not_needed", >+ line => "[% var | \$KohaDates with_hours => 1 | html %]", >+ line_number => 4, >+ } >+ ] >+ ); >+ >+}; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22007
:
83248
|
83249
|
83250
|
83251
|
83286
|
83287
|
83288
|
83289
|
83561
|
83562
|
83563
|
83564