* (bug 15099) Bad regexes make the at least some of the blacklist get ignored

Lines with "\" at the end would silently break both that and the following line in the batch, without triggering the overall parse errors.
Added a specific check for this case to skip the bad lines when building, and to check for them and report a warning during editing.
This commit is contained in:
Brion Vibber 2008-08-11 01:32:38 +00:00
parent 65a365fa95
commit 2ca85c4af2

View file

@ -413,6 +413,13 @@ class SpamRegexBatch {
$regexEnd = ($batchSize > 0 ) ? ')/Si' : ')/i';
$build = false;
foreach( $lines as $line ) {
if( substr( $line, -1, 1 ) == "\\" ) {
// Final \ will break silently on the batched regexes.
// Skip it here to avoid breaking the next line;
// warnings from getBadLines() will still trigger on
// edit to keep new ones from floating in.
continue;
}
// FIXME: not very robust size check, but should work. :)
if( $build === false ) {
$build = $line;
@ -497,13 +504,22 @@ class SpamRegexBatch {
*/
static function getBadLines( $lines ) {
$lines = SpamRegexBatch::stripLines( $lines );
$regexes = SpamRegexBatch::buildRegexes( $lines );
if( SpamRegexBatch::validateRegexes( $regexes ) ) {
// No problems!
return array();
}
$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 ) ) {