Bugzilla – Attachment 19970 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-handl.patch (text/plain), 2.00 KB, created by
Mirko Tietgen
on 2013-07-27 23:22:05 UTC
(
hide
)
Description:
Bug 10625 - Inventory/Stocktaking tool cannot handle windows file uploads
Filename:
MIME Type:
Creator:
Mirko Tietgen
Created:
2013-07-27 23:22:05 UTC
Size:
2.00 KB
patch
obsolete
>From e23eb847d95d1984dd43c478059f02126d7e81dd Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 22 Jul 2013 14:30:49 -0400 >Subject: [PATCH] Bug 10625 - Inventory/Stocktaking tool cannot handle windows file uploads > >The inventory/stocktaking tool interprets windows text editor file as a >single large barcode because the text editor only uses carriage returns >for line breaks, rather than a carriage return and line break >combination. This tools should be able to handle \r, \n, and/or \r\n. > >Test Plan: >1) Download the attached sample file of barcodes >2) Upload this file to the inventory/stocktaking tool. > For this test, it doesn't matter that these barcodes aren't > cataloged in your system. >3) Note that the "barcode not found" is a single extremely long barcode >4) Apply this patch >5) Repeat step 2 >6) Note that you now get a "barcode not found" error for each barcode > individually. > >Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net> >--- > tools/inventory.pl | 10 ++++++++-- > 1 files changed, 8 insertions(+), 2 deletions(-) > >diff --git a/tools/inventory.pl b/tools/inventory.pl >index fdf3161..5c115f1 100755 >--- a/tools/inventory.pl >+++ b/tools/inventory.pl >@@ -21,6 +21,8 @@ > use strict; > use warnings; > >+use File::Slurp qw(read_file); >+ > #need to open cgi and get the fh before anything else opens a new cgi context (see C4::Auth) > use CGI; > my $input = CGI->new; >@@ -147,8 +149,12 @@ if ($uploadbarcodes && length($uploadbarcodes)>0){ > my $qwthdrawn = $dbh->prepare($strsth); > my @errorloop; > my $count=0; >- while (my $barcode=<$uploadbarcodes>){ >- $barcode =~ s/\r?\n$//; >+ >+ # This allows us to handle files where lines are delimited by \r, \n, or \r\n. >+ my $file_contents = read_file( $uploadbarcodes ); >+ my @barcodes = split( /\r\n|\n|\r/, $file_contents ); >+ >+ for my $barcode ( @barcodes ){ > if ($qwthdrawn->execute($barcode) &&$qwthdrawn->rows){ > push @errorloop, {'barcode'=>$barcode,'ERR_WTHDRAWN'=>1}; > }else{ >-- >1.7.2.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 10625
:
19857
|
19858
|
19970
|
20466
|
37846
|
37848
|
38572
|
38573
|
38574
|
38575
|
38576
|
38730
|
39959