Koha/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.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

390 lines
21 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE KohaDates %]
[% USE Branches %]
[% USE ItemTypes %]
[% SET footerjs = 1 %]
[% SET article_requests_view = 1 %]
[% SET biblionumber = biblio.biblionumber %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Circulation &rsaquo; Request article</title>
[% INCLUDE 'doc-head-close.inc' %]
[% Asset.css("css/datatables.css") | $raw %]
</head>
<body id="circ_request-article" class="circ">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'circ-search.inc' %]
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
&rsaquo;
<a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
[% UNLESS blocking_error %]
&rsaquo;
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | html %]">[% biblio.title | html %]</a>
&rsaquo;
Request article
[% END %]
</div>
[% INCLUDE 'blocking_errors.inc' %]
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<h1>Request article from <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.id | html %]">[% biblio.title | html %]</a></h1>
[% IF no_patrons_found %]
<div class="dialog alert">
<h3>Patron not found</h3>
<p>No patron with this name, please, try another</p>
</div>
[% ELSIF patrons %]
<form id="article_request_patron_results" method="post">
<fieldset>
<table id="table_borrowers">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Cardnumber</th>
<th>Category</th>
<th>Library</th>
<th>Address</th>
</tr>
</thead>
<tbody>
[% FOREACH patron IN patrons %]
<tr>
<td><input type="radio" name="patron_id" value="[% patron.borrowernumber | html %]"/></td>
<td>[% patron.surname | html %], [% patron.firstname | html %]</td>
<td>[% patron.cardnumber | html %]</td>
<td>[% patron.categorycode | html %]</td>
<td>[% patron.branchcode | html %]</td>
<td>[% patron.address | html %]</td>
</tr>
[% END %]
</tbody>
</table>
<input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
<fieldset class="action"><input type="submit" value="Select" /></fieldset>
</fieldset>
</form>
[% ELSIF !patron %]
<form id="article_requests_patronsearch" action="request-article.pl" method="post">
<fieldset class="brief">
<label for="patron">Patron: </label>
<div class="hint">Enter patron card number or partial name:</div>
<input type="text" size="40" id="patron" class="focus" name="patron_cardnumber" />
<input type="submit" value="Search" />
<input type="hidden" name="biblionumber" value="[% biblio.id | html %]" />
</fieldset>
</form>
[% ELSE %]
[% IF biblio.can_article_request( patron ) %]
<form id="place-article-request" method="post" action="/cgi-bin/koha/circ/request-article.pl">
<input type="hidden" name="action" value="create" />
<input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.id | html %]" />
<fieldset class="rows">
<legend>Place article request from [% biblio.title | html %] for [% patron.firstname | html %] [% patron.surname | html %] ( [% patron.cardnumber | html %] )</legend>
<p/>
<ul>
<li>
<label for="title">Title:</label>
<input type="text" name="title" id="title" size="50"/>
</li>
<li>
<label for="author">Author:</label>
<input type="text" name="author" id="author" size="50"/>
</li>
<li>
<label for="volume">Volume:</label>
<input type="text" name="volume" id="volume" size="50"/>
</li>
<li>
<label for="issue">Issue:</label>
<input type="text" name="issue" id="issue" size="50"/>
</li>
<li>
<label for="date">Date:</label>
<input type="text" name="date" id="date" size="50"/>
</li>
<li>
<label for="pages">Pages:</label>
<input type="text" name="pages" id="pages" size="50"/>
</li>
<li>
<label for="chapters">Chapters:</label>
<input type="text" name="chapters" id="chapters" size="50"/>
</li>
<li>
<label for="patron_notes">Patron notes:</label>
<input type="text" name="patron_notes" id="patron_notes" size="50"/>
</li>
<li>
<label for="branchcode">Pickup library:</label>
<select name="branchcode" id="branchcode">
[% FOREACH b IN Branches.all %]
[% IF b.branchcode == Branches.GetLoggedInBranchcode %]
<option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
[% ELSE %]
<option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
[% END %]
[% END %]
</select>
</li>
</ul>
</fieldset>
[% SET article_request_type = biblio.article_request_type( patron ) %]
[% IF article_request_type != 'bib_only' %]
<table id="current-requests-table" class="ar-table table table-bordered table-striped">
<caption>Select item:</caption>
<thead>
<tr>
<th>&nbsp;</th>
<th>Item type</th>
<th>Barcode</th>
<th>Home library</th>
<th>Call number</th>
<th>Enumeration</th>
</tr>
</thead>
<tbody>
[% FOREACH item IN biblio.items %]
[% IF item.can_article_request( patron ) %]
<tr>
<td>
[% IF article_request_type == 'item_only' && !checked %]
[% SET checked = 1 %]
<input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" checked="checked" />
[% ELSE %]
<input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
[% END %]
</td>
<td>
[% ItemTypes.GetDescription( item.itype ) | html %]
</td>
<td>
[% item.barcode | html %]
</td>
<td>
[% Branches.GetName( item.homebranch ) | html %]
</td>
<td>
[% item.itemcallnumber | html %]
</td>
<td>
[% item.enumchron | html %]
</td>
</tr>
[% END %]
[% END %]
[% IF article_request_type != 'item_only' %]
<tr>
<td>
<input type="radio" name="itemnumber" value="" checked="checked"/>
</td>
<td colspan="5">
Any item
</td>
</tr>
[% END %]
</tbody>
</table>
[% END %]
<p>
<input type="submit" class="btn btn-default" value="Place request" />
</p>
</form>
[% ELSE %]
No article requests can be made for this record.
[% END %]
[% END %]
[% IF biblio.article_requests_current && !patron %]
<fieldset class="rows left" id="current-article-requests-fieldset">
<legend>Current article requests</legend>
<table id="current-article-requests-table">
<tr>
<th>Placed on</th>
<th>Patron</th>
<th>Title</th>
<th>Author</th>
<th>Volume</th>
<th>Issue</th>
<th>Date</th>
<th>Pages</th>
<th>Chapters</th>
<th>Patron notes</th>
<th>Item</th>
<th>Status</th>
<th>Pickup library</th>
<th>&nbsp;</th>
</tr>
[% FOREACH ar IN biblio.article_requests_current %]
<tr>
<td>[% ar.created_on | $KohaDates %]</td>
<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% ar.borrowernumber | html %]">[% ar.borrower.firstname | html %] [% ar.borrower.surname | html %]</a></td>
<td>[% ar.title | html %]</td>
<td>[% ar.author | html %]</td>
<td>[% ar.volume | html %]</td>
<td>[% ar.issue | html %]</td>
<td>[% ar.date | html %]</td>
<td>[% ar.pages | html %]</td>
<td>[% ar.chapters | html %]</td>
<td>[% ar.patron_notes | html %]</td>
<td>
[% IF ar.item %]
<a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% ar.itemnumber | html %]&biblionumber=[% ar.biblionumber | html %]">[% ar.item.barcode | html %]</a>
[% END %]
</td>
<td>
[% IF ar.status == 'PENDING' %]
Pending
[% ELSIF ar.status == 'PROCESSING' %]
Processing
[% ELSIF ar.status == 'COMPLETED' %]
Completed
[% ELSIF ar.status == 'CANCELED' %]
Canceled
[% END %]
</td>
<td>
<i id="update-processing-[% ar.id | html %]" class="fa fa-cog fa-spin hidden"></i>
<select name="branchcode" id="branchcode-[% ar.id | html %]" class="ar-update-branchcode">
[% FOREACH b IN Branches.all %]
[% IF b.branchcode == ar.branchcode %]
<option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
[% ELSE %]
<option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
[% END %]
[% END %]
</select>
</td>
<td>
<a title="Cancel article request" href="#" id="cancel-[% ar.id | html %]" class="ar-cancel-request">
<i id="cancel-processing-spinner-[% ar.id | html %]" class="fa fa-cog fa-spin hide"></i>
<i id="cancel-processing-[% ar.id | html %]" class="fa fa-times fa-lg" style="color:red"></i>
</a>
</td>
</tr>
[% END %]
</table>
</fieldset>
[% END %]
</div>
</div>
<div class="yui-b">
[% INCLUDE 'biblio-view-menu.inc' %]
</div>
</div>
</div>
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript">
$('#current-article-requests').ready(function() {
$(".hide").hide();
});
$(document).ready(function() {
[% UNLESS (patron ) %]
$( "#patron" ).autocomplete({
source: "/cgi-bin/koha/circ/ysearch.pl",
minLength: 3,
select: function( event, ui ) {
$( "#patron" ).val( ui.item.cardnumber );
$( "#holds_patronsearch" ).submit();
return false;
}
})
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "ui-autocomplete-item", item )
.append( "<a>" + item.surname + ", " + item.firstname +
" (" + item.cardnumber + ") <small>" + item.address +
" " + item.city + " " + item.zipcode + " " +
item.country + "</small></a>" )
.appendTo( ul );
};
[% END %]
$( ".ar-update-branchcode" ).on('focus', function(){
previous_branchcode = this.value;
}).on('change', function(){
var branchcode = this.value;
var c = confirm(_("Are you sure you want to change the pickup library from %s to %s for this request?").format( previous_branchcode, branchcode ));
if ( c ) {
var id = this.id.split("branchcode-")[1];
$("#update-processing-" + id ).css({opacity: 0, visibility: "visible"}).animate({opacity: 1.0}, 200);
$.ajax({
type: "POST",
url: '/cgi-bin/koha/svc/article_request',
data: {
action: 'update_branchcode',
id: id,
branchcode: branchcode,
},
success: function( data ) {
$("#update-processing-" + id ).css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 200);
},
dataType: 'json'
});
} else {
this.value = previous_branchcode;
}
});
$(".ar-cancel-request").on("click", function(){
var a = $(this);
var notes = prompt(_("Reason for cancellation:"));
if ( notes != null ) {
var id = this.id.split("cancel-")[1];
$("#cancel-processing-" + id ).hide('slow');
$("#cancel-processing-spinner-" + id ).show('slow');
$.ajax({
type: "POST",
url: '/cgi-bin/koha/svc/article_request',
data: {
action: 'cancel',
id: id,
notes: notes
},
success: function( data ) {
a.parents('tr').hide('slow');
},
dataType: 'json'
});
}
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]