[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 07:20:33 CEST 2015


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

--- Comment #10 from M. Tompsett <mtompset at hotmail.com> ---
Created attachment 37846
  -->
http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=37846&action=edit
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.

--- BEGIN EXAMPLE ---
BARCODE1\n
BARCODE2\r
BARCODE3\r\n
--- END EXAMPLE ---
$ echo "BARCODE1\nBARCODE2\rBARCODE3\r\n" | sed -e "s#\\\\n#\\n#g" | sed -e
"s#\\\\r#\\r#g" > test.txt

2) Log into staff client
3) Tools -> Inventory/stocktaking
4) Click 'Browse' and select the file to upload (e.g. test.txt)
5) Click 'Submit'
6) A Javascript warning comes up, click 'Yes'
   -- This will take a LONG time, at least 1 minute.
   -- eventual results will be wrong.
7) Apply patch
8) repeat steps 3-6
   -- This time correct number of barcodes will be given.
9) run koha qa test tools

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


More information about the Koha-bugs mailing list