/** * Returns an array of invalid lines * * @param array $lines * @return array of input lines which produce invalid input, or empty array if no problems */ static function getBadLines( $lines ) { $lines = SpamRegexBatch::stripLines( $lines ); $badLines = array(); foreach( $lines as $line ) { if( substr( $line, -1, 1 ) == "\\" ) { // Final \ will break silently on the batched regexes. $badLines[] = $line; } } $regexes = SpamRegexBatch::buildRegexes( $lines ); if( SpamRegexBatch::validateRegexes( $regexes ) ) { // No other problems! return $badLines; } // Something failed in the batch, so check them one by one. foreach( $lines as $line ) { $regexes = SpamRegexBatch::buildRegexes( array( $line ) ); if( !SpamRegexBatch::validateRegexes( $regexes ) ) { $badLines[] = $line; } } return $badLines; }