From c7f2fa9d9841b3d8fe06ae4f06896626ccf6c804 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 11 Apr 2013 12:48:26 +0200 Subject: [PATCH] Bug 8896 QA Followup for regex Making sure that the regex does not kill more than it should. Amended: does now only look at separating colons(;) not commas(,). Amended: two index expressions in direct context replaced by same regex for consistency. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- C4/Serials.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 784916c..e2748ff 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1134,21 +1134,18 @@ sub ModSerialStatus { $sth->execute($subscriptionid); my ( $missinglist, $recievedlist ) = $sth->fetchrow; if ( $status == 2 ) { - $recievedlist .= "; $serialseq" - unless ( index( "$recievedlist", "$serialseq" ) >= 0 ); + if $recievedlist!~/(^|;)\s*$serialseq(?=;|$)/; } # in case serial has been previously marked as missing if (grep /$status/, (1,2,3,7)) { - $missinglist =~ s/[,;]?\s?$serialseq//g; + $missinglist=~ s/(^|;)\s*$serialseq(?=;|$)//g; } - # warn "missinglist : $missinglist serialseq :$serialseq, ".index("$missinglist","$serialseq"); $missinglist .= "; $serialseq" - if ( $status == 4 - and not index( "$missinglist", "$serialseq" ) >= 0 ); + if $status==4 && $missinglist!~/(^|;)\s*$serialseq(?=;|$)/; $missinglist .= "; not issued $serialseq" - if ( $status == 5 - and index( "$missinglist", "$serialseq" ) >= 0 ); + if $status==5 && $missinglist!~/(^|;)\s*$serialseq(?=;|$)/; + $query = "UPDATE subscriptionhistory SET recievedlist=?, missinglist=? WHERE subscriptionid=?"; $sth = $dbh->prepare($query); $recievedlist =~ s/^; //; -- 1.7.10.4