MediaWiki REL1_33
SpamRegexBatch Class Reference

Utility class for working with blacklists. More...

Static Public Member Functions

static getBadLines ( $lines, BaseBlacklist $blacklist)
 Returns an array of invalid lines.
 
static regexesFromMessage ( $message, BaseBlacklist $blacklist)
 Build a set of regular expressions from a MediaWiki message.
 
static regexesFromText ( $source, BaseBlacklist $blacklist, $fileName=false)
 Build a set of regular expressions from the given multiline input text, with empty lines and comments stripped.
 

Static Private Member Functions

static buildRegexes ( $lines, BaseBlacklist $blacklist, $batchSize=4096)
 Build a set of regular expressions matching URLs with the list of regex fragments.
 
static buildSafeRegexes ( $lines, BaseBlacklist $blacklist, $fileName=false)
 Do a sanity check on the batch regex.
 
static stripLines ( $lines)
 Strip comments and whitespace, then remove blanks.
 
static validateRegexes ( $regexes)
 Confirm that a set of regexes is either empty or valid.
 

Detailed Description

Utility class for working with blacklists.

Definition at line 6 of file SpamRegexBatch.php.

Member Function Documentation

◆ buildRegexes()

static SpamRegexBatch::buildRegexes ( $lines,
BaseBlacklist $blacklist,
$batchSize = 4096 )
staticprivate

Build a set of regular expressions matching URLs with the list of regex fragments.

Returns an empty list if the input list is empty.

Parameters
array$lineslist of fragments which will match in URLs
BaseBlacklist$blacklist
int$batchSizelargest allowed batch regex; if 0, will produce one regex per line
Returns
array

Definition at line 17 of file SpamRegexBatch.php.

References $line, $lines, and(), BaseBlacklist\getRegexEnd(), and BaseBlacklist\getRegexStart().

Referenced by buildSafeRegexes(), and getBadLines().

◆ buildSafeRegexes()

static SpamRegexBatch::buildSafeRegexes ( $lines,
BaseBlacklist $blacklist,
$fileName = false )
staticprivate

Do a sanity check on the batch regex.

Parameters
array$linesunsanitized input lines
BaseBlacklist$blacklist
bool | string$fileNameoptional for debug reporting
Returns
array of regexes

Definition at line 96 of file SpamRegexBatch.php.

References $lines, buildRegexes(), stripLines(), and wfDebugLog().

Referenced by regexesFromText().

◆ getBadLines()

static SpamRegexBatch::getBadLines ( $lines,
BaseBlacklist $blacklist )
static

Returns an array of invalid lines.

Parameters
array$lines
BaseBlacklist$blacklist
Returns
array of input lines which produce invalid input, or empty array if no problems

Definition at line 119 of file SpamRegexBatch.php.

References $line, $lines, and(), buildRegexes(), and stripLines().

Referenced by SpamBlacklistHooks\validate().

◆ regexesFromMessage()

static SpamRegexBatch::regexesFromMessage ( $message,
BaseBlacklist $blacklist )
static

Build a set of regular expressions from a MediaWiki message.

Will be correctly empty if the message isn't present.

Parameters
string$message
BaseBlacklist$blacklist
Returns
array of regular expressions, potentially empty

Definition at line 168 of file SpamRegexBatch.php.

References $source, regexesFromText(), and wfMessage().

Referenced by BaseBlacklist\getLocalBlacklists(), and BaseBlacklist\getWhitelists().

◆ regexesFromText()

static SpamRegexBatch::regexesFromText ( $source,
BaseBlacklist $blacklist,
$fileName = false )
static

Build a set of regular expressions from the given multiline input text, with empty lines and comments stripped.

Parameters
string$source
BaseBlacklist$blacklist
bool | string$fileNameoptional, for reporting of bad files
Returns
array of regular expressions, potentially empty

Definition at line 155 of file SpamRegexBatch.php.

References $lines, $source, and buildSafeRegexes().

Referenced by BaseBlacklist\buildSharedBlacklists(), and regexesFromMessage().

◆ stripLines()

static SpamRegexBatch::stripLines ( $lines)
staticprivate

Strip comments and whitespace, then remove blanks.

Parameters
array$lines
Returns
array

Definition at line 81 of file SpamRegexBatch.php.

References $lines, and and().

Referenced by buildSafeRegexes(), and getBadLines().

◆ validateRegexes()

static SpamRegexBatch::validateRegexes ( $regexes)
staticprivate

Confirm that a set of regexes is either empty or valid.

Parameters
array$regexesset of regexes
Returns
bool true if ok, false if contains invalid lines

Definition at line 61 of file SpamRegexBatch.php.

References and().


The documentation for this class was generated from the following file: