Koha/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt
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

368 lines
26 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo;
[% IF ( searchdesc ) %]
Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %]
[% ELSE %]
You did not specify any search criteria.
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
<link rel="alternate" type="application/rss+xml" title="Koha - RSS"
href="/cgi-bin/koha/opac-rss.pl?[% query_cgi | html %][% limit_cgi | html %]" />
</head>
[% INCLUDE 'bodytag.inc' bodyid='results-grouped' %]
[% INCLUDE 'masthead.inc' %]
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
<li>
[% IF ( searchdesc ) %]
<a href="#">Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %]</a>
[% ELSE %]
<a href="#">You did not specify any search criteria.</a>
[% END %]
</li>
</ul>
[% IF ( query_error ) %]
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class="alert">
<h4>Error:</h4>
<p>[% query_error | html %]</p>
</div>
</div> <!-- / .span12 -->
</div> <!-- / .row-fluid -->
</div> <!-- / .container-fluid -->
[% END %]
<div class="container-fluid">
<div class="row-fluid">
[% IF ( opacfacets && total ) %]
<div class="span2">
<div id="facetcontainer">
<!-- FACETS START -->
[% INCLUDE 'opac-facets.inc' %]
<!-- FACETS END -->
</div>
</div>
<div class="span10">
[% ELSE %]
<div class="span12">
[% END %]
<div id="grouped-results">
<!-- Search Results Table -->
[% IF ( total ) %]
[% IF ( scan ) %]
<h1>Scan index:</h1>
<form action="/cgi-bin/koha/opac-search.pl" method="get">
<table>
<tbody>
<tr>
<td>
Scan index for: <input type="text" name="q" id="scan-index" size="35" value="" />
</td>
</tr>
<tr>
<td>
<label for="scan-index">Indexed in:</label>
<select name="idx" id="scan-index">
<option value="">Any word</option>
<option value="kw,phr:">Any phrase</option>
<option value="ti:">Title</option>
<option value="ti,phr:">Title phrase</option>
<option value="au,phr:">Author</option>
<option value="su:">Subject</option>
<option value="su,phr:">Subject phrase</option>
<option value="se:">Series</option>
<option value="pb:">Publisher</option>
<option value="nt:">Notes</option>
<option value="se:">Series Title</option>
<option value="sn:">ISBN</option>
<option value="ss:">ISSN</option>
</select>
<input type="hidden" name="scan" value="1" />
</td>
</tr>
</tbody>
</table>
</form>
<form action="/cgi-bin/koha/opac-search.pl" method="get">
<table>
<thead>
<tr>
<th>Term/Phrase</th>
<th>Count</th>
</tr>
</thead>
<tbody>
[% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %]
<tr>
<td>
<a href="/cgi-bin/koha/opac-search.pl?q=[% SEARCH_RESULT.scan_use |url %]&quot;[% SEARCH_RESULT.title |url %]&quot;">[% SEARCH_RESULT.title | html %]</a>
</td>
<td>
[% FOREACH subtitl IN SEARCH_RESULT.subtitle %]
[% subtitl.subfield | html %]
[% END %]
</td>
</tr>
[% END %]
</thead>
</table>
</form>
[% ELSE %]
<div class="searchresults">
<form action="/cgi-bin/koha/opac-search.pl" method="get" name="bookbag_form" id="bookbag_form">
[% IF ( searchdesc ) %]
[% FOREACH QUERY_INPUT IN QUERY_INPUTS %]
<input type="hidden" name="[% QUERY_INPUT.input_name | html %]" value="[% QUERY_INPUT.input_value | html %]"/>
[% END %]
[% FOREACH LIMIT_INPUT IN LIMIT_INPUTS %]
<input type="hidden" name="[% LIMIT_INPUT.input_name | html %]" value="[% LIMIT_INPUT.input_value | html %]"/>
[% END %]
[% END %]
<!-- TABLE RESULTS START -->
<table class="table table-striped">
<tr>
<td colspan="3" class="resultscontrol">
<div class="resort">
<select id="sort_by" name="sort_by"> [% INCLUDE 'resort_form.inc' %] </select>
<input type="submit" class="submit clearfix" id="sortsubmit" value="Go" />
</div>
[% IF ( ( Koha.Preference( 'opacbookbag' ) == 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
<div class="cartlist"><span class="checkall"></span>
<span class="clearall"></span>
<a href="#" class="highlight_toggle" id="highlight_toggle_off">Unhighlight</a>
<a href="#" class="highlight_toggle" id="highlight_toggle_on">Highlight</a>
<span class="addto"></span></div>
[% END %]
</td>
</tr>
<!-- Actual Search Results -->
[% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %]
<tr class="grouplabel"><td colspan="3">[% SEARCH_RESULT.group_label | html %]</td></tr>
[% FOREACH GROUP_RESULT IN SEARCH_RESULT.GROUP_RESULTS %]
[% IF ( GROUP_RESULT.even ) %]
<tr class="highlight">
[% ELSE %]
<tr>
[% END %]
<td>
[% IF ( OPACAmazonCoverImages ) %]
<a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]">[% IF ( GROUP_RESULT.isbn ) %]<img src="https://images-na.ssl-images-amazon.com/images/P/[% GROUP_RESULT.isbn | html %].01.TZZZZZZZ.jpg" alt="" class="thumbnail" />[% ELSE %]<img src="http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif" alt="" class="thumbnail" />[% END %]
</a>
[% ELSE %]
[% UNLESS ( noItemTypeImages ) %]
[% IF ( GROUP_RESULT.imageurl ) %]
<img src="[% GROUP_RESULT.imageurl | html %]" title="[% GROUP_RESULT.description | html %]" />
[% END %]
[% END %]
[% GROUP_RESULT.description | html %]
[% END %]
</td>
<td>
[% GROUP_RESULT.result_number | html %].
[% IF ( GROUP_RESULT.BiblioDefaultViewmarc ) %]
<a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]" title="View details for this title">[% GROUP_RESULT.title | html %]
[% ELSE %]
[% IF ( GROUP_RESULT.BiblioDefaultViewisbd ) %]
<a class="title" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]" title="View details for this title">[% GROUP_RESULT.title | html %]
[% ELSE %]
<a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]" title="View details for this title">[% GROUP_RESULT.title | html %]
[% END %]
[% FOREACH subtitl IN GROUP_RESULT.subtitle %]
[% subtitl.subfield | html %]
[% END %]
</a>
[% END # / IF GROUP_RESULT.BiblioDefaultViewmarc %]
[% IF ( GROUP_RESULT.author ) %]
by <a href="/cgi-bin/koha/opac-search.pl?q=au:[% GROUP_RESULT.author |url %]" title="Search for works by this author">[% GROUP_RESULT.author | html %]</a>
[% ELSE %]
&nbsp;
[% END %]
<p>
[% IF ( GROUP_RESULT.publicationyear ) %] - [% GROUP_RESULT.publicationyear | html %][% END %]
[% IF ( GROUP_RESULT.publishercode ) %]- [% GROUP_RESULT.publishercode | html %][% END %]
[% IF ( GROUP_RESULT.place ) %] ; [% GROUP_RESULT.place | html %][% END %]
[% IF ( GROUP_RESULT.pages ) %] - [% GROUP_RESULT.pages | html %][% END %]
[% IF ( GROUP_RESULT.notes ) %] : [% GROUP_RESULT.notes | html %][% END %]
[% IF ( GROUP_RESULT.size ) %] ; [% GROUP_RESULT.size | html %][% END %]
[% IF ( GROUP_RESULT.timestamp ) %] <i>(modified on [% GROUP_RESULT.timestamp | html %])</i>[% END %]
</p>
[% IF ( GROUP_RESULT.searchhighlightblob ) %]
<p class="searchhighlightblob">[% GROUP_RESULT.searchhighlightblob | html %]</p>
[% END %]
<p class="availability">
[% IF ( GROUP_RESULT.available_items_loop ) %]
<span class="available"><strong>Items available at:</strong>
[% FOREACH available_items_loo IN GROUP_RESULT.available_items_loop %]
[% IF ( available_items_loo.branchname ) %][% available_items_loo.branchname | html %][% END %]
[% IF ( OPACItemsResultsDisplay ) %]
[% IF ( available_items_loo.location ) %][% available_items_loo.location | html %][% END %]
[% IF ( available_items_loo.itemcallnumber ) %][<a href="/cgi-bin/koha/opac-search.pl?q=callnum:[% available_items_loo.itemcallnumber |url %]">[% available_items_loo.itemcallnumber | html %]</a>][% END %]
[% END %]
([% available_items_loo.count | html %]),
[% END # / FOREACH available_items_loo %]
</span>
[% ELSE %]
<span class="unavailable">No items available:</span>
[% END # / IF GROUP_RESULT.available_items_loop %]
<span class="unavailable">
[% IF ( GROUP_RESULT.onloancount ) %] Checked out ([% GROUP_RESULT.onloancount | html %]), [% END %]
[% IF ( GROUP_RESULT.withdrawncount ) %] Withdrawn ([% GROUP_RESULT.withdrawncount | html %]), [% END %]
[% IF ( GROUP_RESULT.itemlostcount ) %] Lost ([% GROUP_RESULT.itemlostcount | html %]),[% END %]
[% IF ( GROUP_RESULT.damagedcount ) %] Damaged ([% GROUP_RESULT.damagedcount | html %]),[% END %]
[% IF ( GROUP_RESULT.orderedcount ) %] On order ([% GROUP_RESULT.orderedcount | html %]),[% END %]
[% IF ( GROUP_RESULT.intransitcount ) %] In transit ([% GROUP_RESULT.intransitcount | html %]),[% END %]
</span>
</p>
<p>
[% IF Koha.Preference( 'RequestOnOpac' ) == 1 %]
[% UNLESS ( GROUP_RESULT.norequests ) %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 && GROUP_RESULT.holdable %]
<a class="hold" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=[% GROUP_RESULT.biblionumber | html %]">Place hold</a><!-- add back when available 0 holds in queue-->
[% END %]
[% END %]
[% END %]
[% IF ( ( Koha.Preference( 'opacbookbag' ) == 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]
<input type="checkbox" name="biblionumber" value="[% GROUP_RESULT.biblionumber | html %]" title="Click to add to cart" /> <label for="bib[% GROUP_RESULT.biblionumber | html %]">
[% END %]
<img src="[% themelang | html %]/images/[% GROUP_RESULT.itemtype | html %].gif" alt="[% GROUP_RESULT.ccode | html %]" title="[% GROUP_RESULT.ccode | html %]" />
[% IF ( ( Koha.Preference( 'opacbookbag' ) = 1 ) || ( Koha.Preference( 'virtualshelves' ) == 1 ) ) %]</label>[% END %]
[% IF ( GROUP_RESULT.classification ) %]
<a href="/cgi-bin/koha/opac-search.pl?q=callnum:[% GROUP_RESULT.classification |url %]"> [% GROUP_RESULT.classification | html %] </a>
[% END %]
</p>
</td>
</tr>
[% END # / FOREACH GROUP_RESULT %]
[% END # / FOREACH SEARCH_RESULTS %]
</table>
</form>
</div> <!-- / .searchresults -->
[% END # / IF scan %]
[% INCLUDE 'page-numbers.inc' %]
[% END # / IF total %]
[% IF Koha.Preference( 'suggestion' ) == 1 && ( Koha.Preference( 'AnonSuggestions' ) == 1 || loggedinusername || Koha.Preference( 'ILLModule' ) == 1 ) %]
<div class="suggestion">
Not finding what you're looking for?
<ul>
[% IF Koha.Preference( 'AnonSuggestions' ) == 1 %]
<li>Make a <a href="/cgi-bin/koha/opac-suggestions.pl?op=add">purchase suggestion</a></li>
[% ELSE %]
[% IF ( loggedinusername ) %]
<li>Make a <a href="/cgi-bin/koha/opac-suggestions.pl?op=add">purchase suggestion</a></li>
[% END %]
[% END %]
[% IF Koha.Preference( 'ILLModule' ) == 1 && loggedinusername %]
<li>Make an <a href="/cgi-bin/koha/opac-illrequests.pl?op=create">Interlibrary loan request</a></li>
[% END %]
</ul>
</div>
[% END %]
</div> <!-- / #grouped-results -->
</div> <!-- /.span10/12 -->
</div> <!-- / .row-fluid -->
</div> <!-- / .container-fluid -->
</div><!-- / .main -->
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
<script>
//<![CDATA[
var q_array = new Array(); // will hold the search terms, if possible
$(document).ready(function(){
[% IF ( OpacHighlightedWords ) %]
$('a.title').each(function() {
$(this).attr("href", $(this).attr("href") + "&query_desc=[% query_desc | uri %]");
});
[% END %]
$('#sortsubmit').hide();
$('#sort_by').change(function() {
$('#bookbag_form').submit();
});
$("span.clearall").html("<a id=\"CheckNone\" href=\"#\">" + _("Clear all") + "</a>");
$("span.checkall").html("<a id=\"CheckAll\" href=\"#\">" + _("Select all") + "</a>");
$("span.addto").html("<label for=\"addto\">" + _("Add to: ") + "</label><select name=\"addto\" id=\"addto\"><option value=\"\"></option>[% IF Koha.Preference( 'opacbookbag' ) == 1 %]<option value=\"addtocart\">" + _("Cart") + "</option>[% END %][% IF Koha.Preference( 'virtualshelves' ) == 1 %][% IF ( loggedinusername ) %]<optgroup label=\"" + _("Lists:") + "\">[% IF ( barshelves ) %][% FOREACH barshelvesloo IN barshelvesloop %][% IF ( category == 1 ) %]<option id=\"s[% barshelvesloo.shelfnumber | html %]\" value=\"addtolist\">[% barshelvesloo.shelfname | html %]</option>[% END %][% END %][% END %]<option value=\"newlist\">" + _("[ New list ]") + "</option></optgroup>[% ELSE %]<option value=\"newlist\">" + _("List") + "</option>[% END %][% END %]</select> <input type=\"submit\" class=\"submit\" value=\"" + _("Save") + "\" />");
$("#addto").change(function(){
cartList();
});
$(".addto").find("input:submit").click(function(){
cartList();
return false;
});
function cartList(){
if($("#addto").find("option:selected").attr("value") == "addtolist"){
var shelfnumber = $("#addto").find("option:selected").attr("id").replace("s","");
[% IF ( loggedinusername ) %]if (vShelfAdd()) {
Dopop('/cgi-bin/koha/opac-addbybiblionumber.pl?selectedshelf='+shelfnumber+'&' + vShelfAdd());
}[% ELSE %] alert(_("You must be logged in to create or add to Lists")); [% END %]
return false;
} else if($("#addto").find("option:selected").attr("value") == "newlist"){
[% IF ( loggedinusername ) %]if (vShelfAdd()) {
Dopop('/cgi-bin/koha/opac-addbybiblionumber.pl?newshelf=1&' + vShelfAdd());
}[% ELSE %] alert(_("You must be logged in to create or add to Lists")); [% END %]
return false;
}
if($("#addto").find("option:selected").attr("value") == "addtocart"){
addMultiple();
return false;
}
}
$("#CheckAll").click(function(){
$("#bookbag_form").checkCheckboxes();
return false;
});
$("#CheckNone").click(function(){
$("#bookbag_form").unCheckCheckboxes();
return false;
});
[% IF ( query_desc ) %]
var query_desc = "[% query_desc |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
q_array = query_desc.split(" ");
// ensure that we don't have "" at the end of the array, which can
// break the highlighter
while (q_array.length > 0 && q_array[q_array.length-1] == "") {
q_array = q_array.splice(0,-1);
}
highlightOn();
$("#highlight_toggle_on" ).hide().click(function() {highlightOn() ;});
$("#highlight_toggle_off").show().click(function() {highlightOff();});
[% END %]
});
function highlightOff() {
$("td").removeHighlight();
$(".highlight_toggle").toggle();
}
function highlightOn() {
var x;
for (x in q_array) {
q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1");
q_array[x] = q_array[x].toLowerCase();
var myStopwords = "[% Koha.Preference('NotHighlightedWords') | html %]".toLowerCase().split('|');
if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) {
$("td").highlight(q_array[x]);
}
}
$(".highlight_toggle").toggle();
}
//]]>
</script>
[% END %]