Bugzilla – Attachment 9373 Details for
Bug 7977
Add a "Quote-of-the-day" feature to the OPAC homepage
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Adding sanity checks to verify file type and size
Adding-sanity-checks-to-verify-file-type-and-size.patch (text/plain), 1.99 KB, created by
Chris Nighswonger
on 2012-04-30 15:40:45 UTC
(
hide
)
Description:
Adding sanity checks to verify file type and size
Filename:
MIME Type:
Creator:
Chris Nighswonger
Created:
2012-04-30 15:40:45 UTC
Size:
1.99 KB
patch
obsolete
>From b46803b170624c10abf060c1d90e920f6d8e6be2 Mon Sep 17 00:00:00 2001 >From: Chris Nighswonger <cnighswonger@foundations.edu> >Date: Mon, 30 Apr 2012 11:40:04 -0400 >Subject: [PATCH] Adding sanity checks to verify file type and size >Content-Type: text/plain; charset="utf-8" > >http://bugs.koha-community.org/show_bug.cgi?id=7977 >--- > .../prog/en/modules/tools/quotes-upload.tt | 17 +++++++++++++++++ > 1 files changed, 17 insertions(+), 0 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes-upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes-upload.tt >index ed8f80b..0ac5ae1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes-upload.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes-upload.tt >@@ -198,6 +198,7 @@ > reader.onprogress = fnUpdateProgress; > reader.onabort = function(e) { > alert('File read cancelled'); >+ parent.location='quotes-upload.pl'; > }; > reader.onloadstart = function(e) { > document.getElementById('cancel_upload').style.visibility="visible"; >@@ -211,6 +212,22 @@ > quotes = fnCSVToArray(e.target.result, ','); > fnDataTable(quotes); > } >+ >+ // perform various sanity checks on the target file prior to uploading... >+ var fileType = evt.target.files[0].type || 'unknown'; >+ var fileSizeInK = Math.round(evt.target.files[0].size/1024); >+ >+ if (fileType != 'text/csv') { >+ alert('Incorrect filetype: '+fileType+'. Uploads limited to text/csv.'); >+ parent.location='quotes-upload.pl'; >+ return; >+ } >+ if (fileSizeInK > 512) { >+ if (!confirm(evt.target.files[0].name+' is '+fileSizeInK+' K in size. Do you really want to upload this file?')) { >+ parent.location='quotes-upload.pl'; >+ return; >+ } >+ } > // Read in the image file as a text string. > reader.readAsText(evt.target.files[0]); > } >-- >1.7.0.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7977
:
9310
|
9321
|
9323
|
9324
|
9325
|
9326
|
9327
|
9328
|
9338
|
9343
|
9373
|
9376
|
9377
|
9378
|
9392
|
9405
|
9406
|
9407
|
9408
|
9409
|
9433
|
9434
|
9435
|
9441
|
9442
|
9443
|
9447
|
9473
|
9474
|
9475
|
9476
|
9477
|
9478
|
9479
|
9480
|
9481
|
9482
|
9483
|
9484
|
9485
|
9486
|
9503
|
9504
|
9505
|
9510
|
9517
|
9521
|
9529
|
9530
|
9531
|
9682
|
9683
|
9711
|
9712
|
9713
|
9714
|
9715
|
9716
|
9717
|
9718
|
9719
|
9720
|
9721
|
9722
|
9723
|
9724
|
9725
|
9726
|
9727
|
9728
|
9729
|
9730
|
9731
|
9732