Bugzilla – Attachment 37848 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]
[Signed-off] Bug 10625: Inventory/Stocktaking tool cannot handle windows file uploads
Signed-off-Bug-10625-InventoryStocktaking-tool-can.patch (text/plain), 2.74 KB, created by
Marc Véron
on 2015-04-15 06:31:15 UTC
(
hide
)
Description:
[Signed-off] Bug 10625: Inventory/Stocktaking tool cannot handle windows file uploads
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2015-04-15 06:31:15 UTC
Size:
2.74 KB
patch
obsolete
>From cebd63a999e9e9526da56f87a750f0812a256569 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 15 Apr 2015 01:02:08 -0400 >Subject: [PATCH] [Signed-off] Bug 10625: Inventory/Stocktaking tool cannot > handle windows file uploads >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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; > $barcode =~ s/\n$//; > $barcode =~ s/^\n//; > 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) Create a file with at least three different barcodes. > >--- >I tested with the test file provided and with a file where some lines have CR and other lines have CR NL (inserted with Win text editor). >Worked as expected. >Signed-off-by: Marc Véron <veron@veron.ch> >--- > tools/inventory.pl | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > >diff --git a/tools/inventory.pl b/tools/inventory.pl >index b8cc31d..f09abf9 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,15 @@ 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; >+ $barcode =~ s/\n$//; >+ $barcode =~ s/^\n//; >+ my @data = split(/\n/,$barcode); >+ push @uploadedbarcodes, @data; >+ } >+ for my $barcode (@uploadedbarcodes) { > next unless $barcode; > ++$lines_read; > if (length($barcode)>$barcode_size) { >-- >1.7.10.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