Bug 29114: Trim whitespace before the barcode

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 <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit c4ee39bf3a)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Andrii Veremeienko 2021-10-29 16:44:19 +03:00 committed by Lucas Gass
parent 65292aaa86
commit 1e54d08e64

View file

@ -21,6 +21,7 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( get_template_and_user );
use C4::Biblio qw( GetMarcBiblio );
use C4::Circulation qw( barcodedecode );
use C4::Koha qw(
GetNormalizedEAN
GetNormalizedISBN
@ -157,7 +158,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 <cr> separated list
foreach my $barcode (@barcodes){
$barcode =~ s/\r$//; # strip any naughty return chars
$barcode = barcodedecode( $barcode ) if $barcode;
next if $barcode eq '';
my $item = Koha::Items->find({barcode => $barcode});
if ( $item ) {