Bug 8896 QA Followup for regex
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Thu, 11 Apr 2013 10:48:26 +0000 (12:48 +0200)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Mon, 6 May 2013 12:49:36 +0000 (08:49 -0400)
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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/Serials.pm

index 784916c..e2748ff 100644 (file)
@@ -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/^; //;