View | Details | Raw Unified | Return to bug 21393
Collapse All | Expand All

(-)a/t/lib/QA/TemplateFilters.pm (-2 / +4 lines)
Lines 30-36 sub missing_filters { Link Here
30
    my ($content) = @_;
30
    my ($content) = @_;
31
    my ( $use_raw, $has_use_raw );
31
    my ( $use_raw, $has_use_raw );
32
    my @errors;
32
    my @errors;
33
    my $line_number;
33
    for my $line ( split "\n", $content ) {
34
    for my $line ( split "\n", $content ) {
35
        $line_number++;
34
        if ( $line =~ m{\[%[^%]+%\]} ) {
36
        if ( $line =~ m{\[%[^%]+%\]} ) {
35
37
36
            # handle exceptions first
38
            # handle exceptions first
Lines 39-45 sub missing_filters { Link Here
39
41
40
            # Do we have Asset without the raw filter?
42
            # Do we have Asset without the raw filter?
41
            if ( $line =~ m{^\s*\[% Asset} ) {
43
            if ( $line =~ m{^\s*\[% Asset} ) {
42
                push @errors, { error => 'asset_must_be_raw', line => $line }
44
                push @errors, { error => 'asset_must_be_raw', line => $line, line_number => $line_number }
43
                  and next
45
                  and next
44
                  unless $line =~ m{\|\s*\$raw};
46
                  unless $line =~ m{\|\s*\$raw};
45
            }
47
            }
Lines 67-73 sub missing_filters { Link Here
67
                  ;    # We could escape it but should be safe
69
                  ;    # We could escape it but should be safe
68
                next if $tt_block =~ m{^\#};    # Is a comment, skip it
70
                next if $tt_block =~ m{^\#};    # Is a comment, skip it
69
71
70
                push @errors, { error => 'missing_filter', line => $line }
72
                push @errors, { error => 'missing_filter', line => $line, line_number => $line_number }
71
                  if $tt_block !~ m{\|\s?\$raw}   # already escaped correctly with raw
73
                  if $tt_block !~ m{\|\s?\$raw}   # already escaped correctly with raw
72
                  && $tt_block !~ m{=}            # assignment, maybe we should require to use SET (?)
74
                  && $tt_block !~ m{=}            # assignment, maybe we should require to use SET (?)
73
                  && $tt_block !~ m{\|\s?ur(l|i)} # already has url or uri filter
75
                  && $tt_block !~ m{\|\s?ur(l|i)} # already has url or uri filter
(-)a/t/template_filters.t (-27 / +44 lines)
Lines 61-116 INPUT Link Here
61
61
62
my @expected_errors = (
62
my @expected_errors = (
63
    {
63
    {
64
        error  => q{missing_filter},
64
        error => q{missing_filter},
65
        line   => q{        [% just_a_var %] A N D [% another_one_on_same_line %]},
65
        line =>
66
q{        [% just_a_var %] A N D [% another_one_on_same_line %]},
67
        line_number => 6,
66
    },
68
    },
67
    {
69
    {
68
        error  => q{missing_filter},
70
        error => q{missing_filter},
69
        line   => q{        [% just_a_var %] A N D [% another_one_on_same_line %]},
71
        line =>
72
q{        [% just_a_var %] A N D [% another_one_on_same_line %]},
73
        line_number => 6,
70
    },
74
    },
71
    {
75
    {
72
        error  => q{missing_filter},
76
        error => q{missing_filter},
73
        line   => q{    [% IF ( patron.othernames | html ) %]“[% patron.othernames %]”[% END %]},
77
        line =>
78
q{    [% IF ( patron.othernames | html ) %]“[% patron.othernames %]”[% END %]},
79
        line_number => 12,
74
    },
80
    },
75
    {
81
    {
76
        error  => q{asset_must_be_raw},
82
        error       => q{asset_must_be_raw},
77
        line   => q{    [% Asset.css("css/datatables.css").raw %]},
83
        line        => q{    [% Asset.css("css/datatables.css").raw %]},
84
        line_number => 13,
78
    },
85
    },
79
    {
86
    {
80
        error  => q{missing_filter},
87
        error => q{missing_filter},
81
        line   => q{<a href="tel:[% patron.phone %]">[% patron.phone %]</a>},
88
        line  => q{<a href="tel:[% patron.phone %]">[% patron.phone %]</a>},
89
        line_number => 16,
82
    },
90
    },
83
    {
91
    {
84
        error  => q{missing_filter},
92
        error => q{missing_filter},
85
        line   => q{<a href="tel:[% patron.phone %]">[% patron.phone %]</a>},
93
        line  => q{<a href="tel:[% patron.phone %]">[% patron.phone %]</a>},
94
        line_number => 16,
86
    },
95
    },
87
    {
96
    {
88
        error  => q{missing_filter},
97
        error => q{missing_filter},
89
        line   => q{<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>},
98
        line =>
99
q{<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>},
100
        line_number => 17,
90
    },
101
    },
91
    {
102
    {
92
        error  => q{missing_filter},
103
        error => q{missing_filter},
93
        line   => q{<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>},
104
        line =>
105
q{<a title="[% patron.emailpro %]" href="mailto:[% patron.emailpro | uri %]">[% patron.emailpro %]</a>},
106
        line_number => 17,
94
    },
107
    },
95
    {
108
    {
96
        error  => q{missing_filter},
109
        error       => q{missing_filter},
97
        line   => q{[% patron_message.get_column('manager_surname') %]},
110
        line        => q{[% patron_message.get_column('manager_surname') %]},
111
        line_number => 18,
98
    },
112
    },
99
    {
113
    {
100
        error  => q{missing_filter},
114
        error       => q{missing_filter},
101
        line   => q{[%- var -%]},
115
        line        => q{[%- var -%]},
116
        line_number => 29,
102
    },
117
    },
103
    {
118
    {
104
        error  => q{missing_filter},
119
        error       => q{missing_filter},
105
        line   => q{[% - var - %]},
120
        line        => q{[% - var - %]},
121
        line_number => 30,
106
    },
122
    },
107
    {
123
    {
108
        error  => q{missing_filter},
124
        error       => q{missing_filter},
109
        line   => q{[%~ var ~%]},
125
        line        => q{[%~ var ~%]},
126
        line_number => 31,
110
    },
127
    },
111
    {
128
    {
112
        error  => q{missing_filter},
129
        error       => q{missing_filter},
113
        line   => q{[% ~ var ~ %]},
130
        line        => q{[% ~ var ~ %]},
131
        line_number => 32,
114
    }
132
    }
115
);
133
);
116
134
117
- 

Return to bug 21393