mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SpamBlacklist
synced 2024-11-24 07:04:04 +00:00
* (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:
parent
65a365fa95
commit
2ca85c4af2
|
@ -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 ) ) {
|
||||
|
|
Loading…
Reference in a new issue