Bugzilla – Attachment 38576 Details for
Bug 10625
Inventory/Stocktaking tool cannot handle windows file uploads
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10625: Inventory/Stocktaking tool cannot handle windows file uploads
Bug-10625-InventoryStocktaking-tool-cannot-handle-.patch (text/plain), 2.94 KB, created by
Mark Tompsett
on 2015-04-27 20:05:59 UTC
(
hide
)
Description:
Bug 10625: Inventory/Stocktaking tool cannot handle windows file uploads
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-04-27 20:05:59 UTC
Size:
2.94 KB
patch
obsolete
>From b5e3a4c32235fa09f0ad2d52827f583c88568b74 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 15 Apr 2015 01:02:08 -0400 >Subject: [PATCH] Bug 10625: Inventory/Stocktaking tool cannot handle windows > file uploads > >The current code uses > $barcode = <fh>; >logic. This reads until \n, as far as I can tell. >EOL is indicated by \n, \r, and \r\n depending on OS and software. >So, to this end, rather than File::Slurp (which is a potential >memory hog, which is already an issue with no filters), a loop >to pre-read the barcodes was written. > >This loop includes: > $barcode =~ s/\r/\n/g; > $barcode =~ s/\n\n/\n/g; > my @data = split(/\n/, $barcode); > push @uploadedbarcodes,@data; > >So, that means that lines ending in \n would have it stripped >and pushed into the uploaded barcodes array. > >Lines ending in \r would likely be read as one giant block, >have everything converted to single \n's and then using a split, >the set of barcodes are pushed into the uploaded barcodes array. > >Lines ending in \r\n would get that stripped and pushed into the >uploaded barcodes array. > >It is then the uploaded barcodes array that is looped over for >validating the barcodes. > >TEST PLAN >--------- > 1) Back up your database > 2) Download the three sample files (or create your own) > 3) Log in to staff client > 4) Create a branch with no inventory. > 5) Home -> Tools -> Inventory/Stocktaking > 6) Browse for your '\r' test file. > 7) Limit to just that branch > 8) Click 'Submit' > -- Confirm expected errors > 9) Repeat steps 5-8 with the '\n' test file. >10) Repeat steps 5-8 with the '\r\n' test file. > -- one of these repetitions should have problems. >11) Apply patch >12) Repeat steps 5-8 for each of the 3 test files. > -- there should be no issues. >13) run koha qa test tools. > >Note: This is a tweak based on Jonathan Druart's comment #16 > I have reset it to needs sign off again. >--- > tools/inventory.pl | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > >diff --git a/tools/inventory.pl b/tools/inventory.pl >index d463d19..ecd8737 100755 >--- a/tools/inventory.pl >+++ b/tools/inventory.pl >@@ -161,6 +161,7 @@ if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { > my $count = 0; > > my @barcodes; >+ my @uploadedbarcodes; > > my $sth = $dbh->column_info(undef,undef,"items","barcode"); > my $barcode_def = $sth->fetchall_hashref('COLUMN_NAME'); >@@ -169,8 +170,13 @@ if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) { > my $err_data=0; > my $lines_read=0; > binmode($uploadbarcodes, ":encoding(UTF-8)"); >- while (my $barcode=<$uploadbarcodes>){ >- $barcode =~ s/\r?\n$//; >+ while (my $barcode=<$uploadbarcodes>) { >+ $barcode =~ s/\r/\n/g; >+ $barcode =~ s/\n\n/\n/g; >+ my @data = split(/\n/,$barcode); >+ push @uploadedbarcodes, @data; >+ } >+ for my $barcode (@uploadedbarcodes) { > next unless $barcode; > ++$lines_read; > if (length($barcode)>$barcode_size) { >-- >2.1.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 10625
:
19857
|
19858
|
19970
|
20466
|
37846
|
37848
|
38572
|
38573
|
38574
|
38575
|
38576
|
38730
|
39959