Bugzilla – Attachment 29659 Details for
Bug 4162
Inventory Tool Fails Silently
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 4162 The inventory tool lacks validation for barcodes
Bug-4162-The-inventory-tool-lacks-validation-for-b.patch (text/plain), 3.99 KB, created by
Mark Tompsett
on 2014-07-12 13:53:03 UTC
(
hide
)
Description:
Bug 4162 The inventory tool lacks validation for barcodes
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2014-07-12 13:53:03 UTC
Size:
3.99 KB
patch
obsolete
>From 57bf709b41302cc38b3a07b8bfe244f8a21c0172 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Sat, 12 Jul 2014 09:42:52 -0400 >Subject: [PATCH] Bug 4162 The inventory tool lacks validation for barcodes > >The inventory tool had no form of validating on what was assumed >to be a valid barcode number. > >To solve this, an extra loop to read before processing was added. >This allows to validate length (<=20 which is the current size of >the barcode field in the items table) and content (assumed that >0-9a-zA-Z was good enough). > >The template was modified to accomodate validation messages >related to the length and content errors. > >TEST PLAN >--------- >1) Attempt to select a file which does not contain barcodes and > is not a text file. > -- a horrible lack of validation and spamminess ensues. >2) Apply patch >3) Create three files. > a) One containing valid barcodes on each line > -- this file should trigger no errors. > b) A copy of the first with an extra line of >20 characters > (e.g. The Quick Red Fox Jumped Over The Brown Fence) > -- this file should trigger the singular error message case. > c) A copy of the second with the last line duplicated > -- this file should trigger the plural error message case. >4) Attempt each of the three files. >5) Run koha-qa tools. >--- > .../prog/en/modules/tools/inventory.tt | 4 ++++ > tools/inventory.pl | 22 ++++++++++++++++++++ > 2 files changed, 26 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >index c2d9a8c..8a8e657 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt >@@ -96,6 +96,10 @@ $(document).ready(function(){ > <h1>Inventory/Stocktaking</h1> > [% IF (moddatecount) %]<div class="dialog message">[% moddatecount %] items modified : datelastseen set to [% date | $KohaDates %]</div>[% END %] > [% IF (errorfile) %]<div class="dialog alert">[% errorfile %] can't be opened</div>[% END %] >+ [% IF (err_length && err_length==1) %]<div class="dialog alert">There was 1 barcode that was too long.</div>[% END %] >+ [% IF (err_length && err_length>1) %]<div class="dialog alert">There were [% err_length %] barcodes that were too long.</div>[% END %] >+ [% IF (err_data && err_data==1) %]<div class="dialog alert">There was 1 barcode that contained at least one non-alphanumeric character.</div>[% END %] >+ [% IF (err_data && err_data>1) %]<div class="dialog alert">There were [% err_data %] barcodes that contained at least one non-alphanumeric character.</div>[% END %] > [% FOREACH error IN errorloop %] > <div class="dialog alert"> > [% error.barcode %] >diff --git a/tools/inventory.pl b/tools/inventory.pl >index f79f9d6..62f2fd9 100755 >--- a/tools/inventory.pl >+++ b/tools/inventory.pl >@@ -160,9 +160,31 @@ if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { > > my $count = 0; > >+ my @barcodes; >+ my $err_length=0; >+ my $err_data=0; > while (my $barcode=<$uploadbarcodes>){ > $barcode =~ s/\r?\n$//; > next unless $barcode; >+ if (length($barcode)>20) { >+ $err_length += 1; >+ } >+ if ($barcode =~ /[^0-9a-zA-Z]/) { >+ $err_data += 1; >+ } >+ next if length($barcode)>20; # 20 is the current length of barcode. >+ next if ( $barcode =~ /[^0-9a-zA-Z]/ ); # Only 0-9a-zA-Z are valid. >+ push @barcodes,$barcode; >+ } >+ if (! @barcodes) { >+ push @errorloop, {'barcode'=>'No valid barcodes!'}; >+ $op=''; # force the initial inventory screen again. >+ } >+ else { >+ $template->param( err_length => $err_length, >+ err_data => $err_data ); >+ } >+ foreach my $barcode (@barcodes) { > if ( $qwithdrawn->execute($barcode) && $qwithdrawn->rows ) { > push @errorloop, { 'barcode' => $barcode, 'ERR_WTHDRAWN' => 1 }; > } else { >-- >1.7.9.5
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 4162
:
29659
|
29660
|
30548
|
30841
|
30880
|
30891
|
30899
|
30922