Koha/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc
Jonathan Druart dcd1f5d48c Bug 13618: Add html filters to all the variables
Here we go, next step then.
As we did not fix the performance issue when autofiltering
the variables (see bug 20975), the only solution we have is to add the
filters explicitely.

This patch has been autogenerated (using add_html_filters.pl, see next
pathces) and add the html filter to all the variables displayed in the
template.
Exceptions are made (using the new 'raw' TT filter) to the variable we
already listed in the previous versions of this patch.

To test:
- Use t/db_dependent/Koha/Patrons.t to populate your DB with autogenerated
data which contain <script> tags

- Remove them from borrower_debarments.comments (there are allowed here)
update  borrower_debarments set comment="html tags possible here";

- From the interface hit page and try to catch alert box.
If you find one it means you find a possible XSS.
To know where it comes from:
* note the exact URL where you found it
* note the alert box content
* Dump your DB and search for the string in the dump to identify its
location (for instance table.field)

Next:
* Ideally we would like to use the raw filter when it is not necessary
to HTML escape the variables (in big loop for instance)
* Provide a QA script to catch missing filters (we want html, uri, url
or raw, certainly others that I am forgetting now)
* Replace the html filters with uri when needed (!)

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

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-08-17 15:55:05 +00:00

95 lines
4.3 KiB
HTML

[% USE AuthorisedValues %]
[% SET itemavailable = 1 %]
[%#- This include takes two parameters: an item structure -%]
[%#- and an optional loan (issue) structure. The issue -%]
[%#- structure is used by course reserves pages, which do -%]
[%#- not use an API to fetch items that populates item.datedue. -%]
[% IF ( item.itemlost ) %]
[% SET itemavailable = 0 %]
[% av_lib_include = AuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) | html %]
[% IF ( av_lib_include ) %]
<span class="item-status lost">[% av_lib_include | html %]</span>
[% ELSE %]
<span class="item-status lost">Item lost</span>
[% END %]
[% END %]
[% IF item.isa('Koha::Item') %]
[% SET datedue = issue.date_due %]
[% SET onsite_checkout = issue.onsite_checkout %]
[% ELSE %]
[% SET datedue = item.datedue || issue.date_due %]
[% SET onsite_checkout = item.onsite_checkout %]
[% END %]
[% IF datedue %]
[% SET itemavailable = 0 %]
[% IF onsite_checkout %]
[% IF ( OPACShowCheckoutName ) %]
<span class="item-status checkedout">Currently in local use by [% item.firstname | html %] [% item.surname | html %] [% IF ( item.cardnumber ) %]([% item.cardnumber | html %])[% END %]</span>
[% ELSE %]
<span class="item-status checkedout">Currently in local use</span>
[% END %]
[% ELSE %]
[% IF ( OPACShowCheckoutName ) %]
<span class="item-status checkedout">Checked out to [% item.firstname | html %] [% item.surname | html %] [% IF ( item.cardnumber ) %]([% item.cardnumber | html %])[% END %]</span>
[% ELSE %]
<span class="item-status checkedout">Checked out</span>
[% END %]
[% END %]
[% END %]
[% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %]
[% SET itemavailable = 0 %]
<span class="item-status intransit">In transit from [% Branches.GetName( item.transfertfrom ) | html %]
to [% Branches.GetName( item.transfertto ) | html %] since [% item.transfertwhen | $KohaDates %]</span>
[% END %]
[% IF NOT( item.isa('Koha::Item') ) AND item.waiting %] [%# Not sure where does come from this waiting flag %]
[% SET itemavailable = 0 %]
<span class="item-status onhold">On hold</span>
[% END %]
[% IF ( item.withdrawn ) %]
[% SET itemavailable = 0 %]
[% av_lib_include = AuthorisedValues.GetByCode( 'WITHDRAWN', item.withdrawn, 1 ) | html %]
[% IF av_lib_include %]
<span class="item-status withdrawn">[% av_lib_include | html %]</span>
[% ELSE %]
<span class="item-status withdrawn">Item withdrawn</span>
[% END %]
[% END %]
[% IF NOT ( item.isa('Koha::Item') ) AND item.itemnotforloan %]
[% SET itemavailable = 0 %]
[% IF ( item.notforloanvalueopac ) %]
<span class="item-status notforloan">[% item.notforloanvalueopac | html %] [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac | html %])</span>[% END %]</span>
[% ELSE %]
<span class="item-status notforloan">Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac | html %])</span>[% END %]</span>
[% END %]
[% ELSIF NOT ( item.isa('Koha::Item') ) AND item.notforloan_per_itemtype %]
[% SET itemavailable = 0 %]
<span class="item-status notforloan">Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac | html %])</span>[% END %]</span>
[% END %]
[% IF ( item.damaged ) %]
[% SET itemavailable = 0 %]
[% av_lib_include = AuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) | html %]
[% IF av_lib_include %]
<span class="item-status damaged">[% av_lib_include | html %]</span>
[% ELSE %]
<span class="item-status damaged">Item damaged</span>
[% END %]
[% END %]
[% IF NOT ( item.isa('Koha::Item') ) AND item.on_order %][%# on_order is only set from opac-detail.pl %]
[% SET itemavailable = 0 %]
<span class="item-status onorder">On order</span>
[% END %]
[% IF ( itemavailable ) %]
[% IF NOT item.isa('Koha::Item') %][% SET restrictedopac = item.restrictedopac %][% END %]
<span class="item-status available">Available [% IF restrictedopac %]<span class="restricted">([% restrictedopac | html %])</span>[% END %]</span>
[% END %]