[Koha-bugs] [Bug 10625] Inventory/Stocktaking tool cannot handle windows file uploads

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Apr 15 08:31:15 CEST 2015


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10625

--- Comment #12 from Marc Véron <veron at veron.ch> ---
Created attachment 37848
  -->
http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=37848&action=edit
[Signed-off] 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;
    $barcode =~ s/\n$//;
    $barcode =~ s/^\n//;
    my @data = split(/\n/, $barcode);
    push @uploadedbarcodes, at 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 at veron.ch>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list