From 390d83267c222fac0b25355dea816a2c251dc81f Mon Sep 17 00:00:00 2001 From: Andrii Veremeienko Date: Sun, 26 Sep 2021 18:06:51 +0300 Subject: [PATCH] Bug 29114: Trim whitespace before the barcode Content-Type: text/plain; charset=utf-8 The solution was to add regexp that trims all whitespaces. How to test: 1. Go to the koha/virtualshelves/shelves.pl; 2. Add new list or edit existing one; 3. Start adding new items; 4. In the "Barcode" field add barcode(s) with whitespaces before them; 5. Observe that it wasn't added as the barcode isn't recognized because of whitespaces; 6. Apply the patch; 7. Repeat step 4; 8. Observe that the item was successfully added; Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- virtualshelves/shelves.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index 25f2127b1c..1ac4d592e9 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -154,6 +154,7 @@ if ( $op eq 'add_form' ) { if ( $shelf->can_biblios_be_added( $loggedinuser ) ) { my @barcodes = split /\n/, $barcodes; # Entries are effectively passed in as a separated list foreach my $barcode (@barcodes){ + $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace $barcode =~ s/\r$//; # strip any naughty return chars next if $barcode eq ''; my $item = Koha::Items->find({barcode => $barcode}); -- 2.20.1