From 1e095c9b4c20d78933ed219d78aa4de5ed44b805 Mon Sep 17 00:00:00 2001 From: Andrii Veremeienko Date: Sat, 30 Oct 2021 14:39:47 +0300 Subject: [PATCH] Bug 29375: Excessive regular expressions There are several places throughout the application where regular expressions are used for the whitespaces trimming together with the normalization function C4::Circulation::barcodedecode. Solution was to remove those regular expressions, because C4::Circulation::barcodedecode trimming whitespaces by itself. How to test: 1. Go to the Koha code base; 2. Do global search by "barcodedecode" key word; 3. Observe that there are several places where barcodedecode used with regular expression together; 4. Apply the patch; 5. Repeat steps 1, 2; 6. Observe that there are no regular expressions used together with barcodedecode; --- circ/circulation.pl | 1 - circ/renew.pl | 1 - circ/returns.pl | 2 -- 3 files changed, 4 deletions(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index 0ec0156612..d9c23d6893 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -158,7 +158,6 @@ if (C4::Context->preference("DisplayClearScreenButton")) { } for my $barcode ( @$barcodes ) { - $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace $barcode = barcodedecode( $barcode ) if $barcode; } diff --git a/circ/renew.pl b/circ/renew.pl index 4a0db8a114..4adc7325f5 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -43,7 +43,6 @@ my $schema = Koha::Database->new()->schema(); my $barcode = $cgi->param('barcode') // ''; my $unseen = $cgi->param('unseen') || 0; -$barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespae $barcode = barcodedecode($barcode) if $barcode; my $override_limit = $cgi->param('override_limit'); my $override_holds = $cgi->param('override_holds'); diff --git a/circ/returns.pl b/circ/returns.pl index 045a30ee31..0f222187eb 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -112,7 +112,6 @@ foreach ( $query->param ) { $counter++; # decode barcode ## Didn't we already decode them before passing them back last time?? - $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace $barcode = barcodedecode($barcode) if $barcode; ###################### @@ -246,7 +245,6 @@ if ($transit) { # actually return book and prepare item table..... my $returnbranch; if ($barcode) { - $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace $barcode = barcodedecode($barcode) if $barcode; my $item = Koha::Items->find({ barcode => $barcode }); -- 2.17.1