dcd1f5d48c
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>
160 lines
7.1 KiB
Text
160 lines
7.1 KiB
Text
[% USE raw %]
|
|
[% USE Asset %]
|
|
[% SET footerjs = 1 %]
|
|
[% INCLUDE 'doc-head-open.inc' %]
|
|
<title>Koha › Tools › Upload images</title>
|
|
[% INCLUDE 'doc-head-close.inc' %]
|
|
<style type="text/css">
|
|
#fileuploadstatus,#fileuploadfailed,#jobpanel,#jobstatus,#jobfailed { display : none; }
|
|
</style>
|
|
</head>
|
|
|
|
<body id="tools_upload-images" class="tools">
|
|
[% INCLUDE 'header.inc' %]
|
|
[% INCLUDE 'cat-search.inc' %]
|
|
|
|
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › [% IF ( uploadimage ) %]<a href="/cgi-bin/koha/tools/upload-cover-image.pl">Upload local cover image</a> › Upload results[% ELSE %]Upload local cover image[% END %]</div>
|
|
|
|
<div id="doc3" class="yui-t2">
|
|
|
|
<div id="bd">
|
|
<div id="yui-main">
|
|
<div class="yui-b">
|
|
|
|
<h1>Upload local cover image</h1>
|
|
[% IF ( uploadimage ) %]
|
|
<p>Image upload results :</p>
|
|
<ul>
|
|
<li>[% total | html %] images found</li>
|
|
[% IF ( error ) %]
|
|
<div class="dialog alert">
|
|
[% IF ( error == 'UZIPFAIL' ) %]<p><b>Failed to unzip archive.<br />Please ensure you are uploading a valid zip file and try again.</b></p>
|
|
[% ELSIF ( error == 'OPNLINK' ) %]<p><b>Cannot open folder index (idlink.txt or datalink.txt) to read.<br />Please verify that it exists.</b></p>
|
|
[% ELSIF ( error == 'OPNIMG' ) %]<p><b>Cannot process file as an image.<br />Please ensure you only upload GIF, JPEG, PNG, or XPM images.</b></p>
|
|
[% ELSIF ( error == 'DELERR' ) %]<p><b>Unrecognized or missing field delimiter.<br />Please verify that you are using either a single quote or a tab.</b></p>
|
|
[% ELSIF ( error == 'DBERR' ) %]<p><b>Unable to save image to database.</b></p>
|
|
[% ELSE %]<p><b>An unknown error has occurred.<br />Please review the error log for more details.</b></p>[% END %]
|
|
</div>
|
|
</li>
|
|
[% END %]
|
|
<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | html %]">View final record</a></li>
|
|
<li><a href="/cgi-bin/koha/tools/tools-home.pl">Back</a></li>
|
|
</ul>
|
|
<hr />
|
|
[% END %]
|
|
<ul>
|
|
<li>Select an image file or ZIP file to upload. The tool will accept images in GIF, JPEG, PNG, and XPM formats.</li>
|
|
</ul>
|
|
<form method="post" action="/cgi-bin/koha/tools/upload-cover-image.pl" id="uploadfile" enctype="multipart/form-data">
|
|
<fieldset class="rows" id="uploadform">
|
|
<legend>Upload images</legend>
|
|
<ol>
|
|
<li>
|
|
<div id="fileuploadform">
|
|
<label for="fileToUpload" class="required">Select the file to upload: </label>
|
|
<input type="file" id="fileToUpload" name="fileToUpload" required="required" class="required" />
|
|
<span class="required">Required</span>
|
|
</div> </li>
|
|
</ol>
|
|
<fieldset class="action"><button class="submit btn btn-default btn-sm">Upload file</button></fieldset>
|
|
</fieldset>
|
|
|
|
<div id="uploadpanel">
|
|
<div id="fileuploadstatus" class="progress_panel">Upload progress:
|
|
<progress max="100" value="0" id="fileuploadprogress">
|
|
</progress>
|
|
<span class="fileuploadpercent">0</span>%
|
|
</div>
|
|
<div id="fileuploadfailed"></div>
|
|
</div>
|
|
</form>
|
|
|
|
<form method="post" id="processfile" action="/cgi-bin/koha/tools/upload-cover-image.pl" enctype="multipart/form-data">
|
|
<fieldset class="rows">
|
|
<input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
|
|
<input type="hidden" name="runinbackground" id="runinbackground" value="" />
|
|
<input type="hidden" name="completedJobID" id="completedJobID" value="" />
|
|
</fieldset>
|
|
<fieldset class="rows">
|
|
<legend>File type</legend>
|
|
<ol>
|
|
<li class="radio">
|
|
[% IF (filetype != 'image' ) %]<input type="radio" id="zipfile" name="filetype" value="zip" checked="checked" />[% ELSE %]<input type="radio" id="zipfile" name="filetype" value="zip" />[% END %]
|
|
<label for="zipfile">ZIP file</label>
|
|
</li>
|
|
<li class="radio">
|
|
[% IF (filetype == 'image' ) %]<input type="radio" id="image" name="filetype" value="image" checked="checked" />[% ELSE %]<input type="radio" id="image" name="filetype" value="image" />[% END %]
|
|
<label for="image">Image file</label>
|
|
</li>
|
|
<li class="radio">
|
|
[% IF ( filetype == 'image' ) %]<span id="bibnum">[% ELSE %]<span id="bibnum" style="display: none">[% END %]<label for="biblionumber">Enter cover biblionumber: </label><input type="text" id="biblionumber" name="biblionumber" value="[% biblionumber | html %]" size="15" /></span>
|
|
</li>
|
|
</ol>
|
|
</fieldset>
|
|
<fieldset class="rows">
|
|
<legend>Options</legend>
|
|
<ol>
|
|
<li class="checkbox">
|
|
[% IF AllowMultipleCovers == 0 %]<input type="checkbox" id="replace" name="replace" checked="checked" disabled="disabled" value="1" />[% ELSE %]<input type="checkbox" id="replace" name="replace" value="1" />[% END %]
|
|
<label for="replace">Replace existing covers</label>
|
|
</li>
|
|
</ol>
|
|
</fieldset>
|
|
<fieldset class="action"><button type="submit" class="btn btn-default btn-sm">Process images</button></fieldset>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="yui-b">
|
|
[% INCLUDE 'tools-menu.inc' %]
|
|
</div>
|
|
</div>
|
|
|
|
[% MACRO jsinclude BLOCK %]
|
|
[% Asset.js("js/tools-menu.js") | $raw %]
|
|
[% Asset.js("js/background-job-progressbar.js") | $raw %]
|
|
[% Asset.js("js/file-upload.js") | $raw %]
|
|
<script type="text/javascript">
|
|
function StartUpload() {
|
|
if( $('#fileToUpload').prop('files').length == 0 ) return;
|
|
$('#uploadform button.submit').prop('disabled',true);
|
|
$("#fileuploadstatus").show();
|
|
$("#uploadedfileid").val('');
|
|
xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
|
|
}
|
|
function cbUpload( status, fileid, errors ) {
|
|
if( status=='done' ) {
|
|
$("#uploadedfileid").val( fileid );
|
|
$('#fileToUpload').prop('disabled',true);
|
|
$("#processfile").show();
|
|
} else {
|
|
var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ];
|
|
var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
|
|
$("#fileuploadstatus").hide();
|
|
$("#fileuploadfailed").show();
|
|
$("#fileuploadfailed").text( _("Upload status: ") +
|
|
( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
|
|
( status=='denied'? _("Denied"): status ))
|
|
);
|
|
$("#processfile").hide();
|
|
}
|
|
}
|
|
$(document).ready(function(){
|
|
$("#processfile").hide();
|
|
$("#zipfile").click(function(){
|
|
$("#bibnum").hide();
|
|
});
|
|
$("#image").click(function(){
|
|
$("#bibnum").show();
|
|
});
|
|
$("#uploadfile").validate({
|
|
submitHandler: function(form) {
|
|
StartUpload();
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
[% END %]
|
|
|
|
[% INCLUDE 'intranet-bottom.inc' %]
|