@@ -, +, @@ --- t/lib/QA/TemplateFilters.pm | 221 ++++++++++++++++++++++---------------------- t/template_filters.t | 4 + 2 files changed, 114 insertions(+), 111 deletions(-) --- a/t/lib/QA/TemplateFilters.pm +++ a/t/lib/QA/TemplateFilters.pm @@ -68,6 +68,23 @@ sub _process_tt_content { $has_use_raw++ if $line =~ m{\[% USE raw %\]}; # Does [% Use raw %] exist? + my $e; + if ( $line =~ qr{(\s|\-|~)*) + (?[^%\-~]+) + (?(\s|\-|~)*) + %\]}gmxs + ) + { + ( $new_line, $e ) = process_tt_block($new_line, { %+, filter => 'uri' }); + push @errors, { line => $line, line_number => $line_number, error => $e } if $e; + } + } + # Loop on TT blocks while ( $line =~ m{ @@ -78,118 +95,10 @@ sub _process_tt_content { %\]}gmxs ) { - my $tt_block = $+{tt_block}; - my $pre_chomp = $+{pre_chomp}; - my $post_chomp = $+{post_chomp}; - - next if - # It's a TT directive, no filters needed - grep { $tt_block =~ $_ } @tt_directives - - # It is a comment - or $tt_block =~ m{^\#} - - # 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?$} - - # Already escaped correctly with raw - or $tt_block =~ m{\|\s?\$raw} - - # Assignment, maybe we should require to use SET (?) - or $tt_block =~ m{=} - - # Already has url or uri filter - or $tt_block =~ m{\|\s?ur(l|i)} - - # Specific for [% foo UNLESS bar %] - or $tt_block =~ m{^(?\S+)\s+UNLESS\s+(?\S+)} - ; - - $pre_chomp = - $pre_chomp - ? $pre_chomp =~ m|-| - ? q|- | - : $pre_chomp =~ m|~| - ? q|~ | - : q| | - : q| |; - $post_chomp = - $post_chomp - ? $post_chomp =~ m|-| - ? q| -| - : $post_chomp =~ m|~| - ? q| ~| - : q| | - : q| |; - - if ( - - # Use the uri filter - # If html filtered or not filtered - $new_line =~ qr{ - [% myuri %] [% myurl %] [% myurl %] +[% another_var %] +[% myuri | html %] [% myurl | html %] [% myurl | html %] +[% another_var | html %] +