MediaWiki  1.30.0
SpamRegexBatch Class Reference

Utility class for working with blacklists. More...

Static Public Member Functions

static buildRegexes ( $lines, BaseBlacklist $blacklist, $batchSize=4096)
 Build a set of regular expressions matching URLs with the list of regex fragments. More...
 
static buildSafeRegexes ( $lines, BaseBlacklist $blacklist, $fileName=false)
 Do a sanity check on the batch regex. More...
 
static getBadLines ( $lines, BaseBlacklist $blacklist)
 Returns an array of invalid lines. More...
 
static regexesFromMessage ( $message, BaseBlacklist $blacklist)
 Build a set of regular expressions from a MediaWiki message. More...
 
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. More...
 
static stripLines ( $lines)
 Strip comments and whitespace, then remove blanks. More...
 
static validateRegexes ( $regexes)
 Confirm that a set of regexes is either empty or valid. More...
 

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 
)
static

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, $regexes, as, BaseBlacklist\getRegexEnd(), and BaseBlacklist\getRegexStart().

Referenced by buildSafeRegexes(), and getBadLines().

◆ buildSafeRegexes()

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

Do a sanity check on the batch regex.

Parameters
$linesstring unsanitized input lines
$blacklistBaseBlacklist
$fileNamebool|string optional for debug reporting
Returns
array of regexes

Definition at line 95 of file SpamRegexBatch.php.

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

Referenced by regexesFromText().

◆ getBadLines()

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

Returns an array of invalid lines.

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

Definition at line 118 of file SpamRegexBatch.php.

References $line, $lines, $regexes, as, 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
$messagestring
$blacklistBaseBlacklist
Returns
array of regular expressions, potentially empty

Definition at line 167 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
$sourcestring
$blacklistBaseBlacklist
$fileNamebool|string optional, for reporting of bad files
Returns
array of regular expressions, potentially empty

Definition at line 154 of file SpamRegexBatch.php.

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

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

◆ stripLines()

static SpamRegexBatch::stripLines (   $lines)
static

Strip comments and whitespace, then remove blanks.

Parameters
$linesarray
Returns
array

Definition at line 80 of file SpamRegexBatch.php.

References $lines.

Referenced by buildSafeRegexes(), and getBadLines().

◆ validateRegexes()

static SpamRegexBatch::validateRegexes (   $regexes)
static

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

Parameters
$regexesarray set of regexes
Returns
bool true if ok, false if contains invalid lines

Definition at line 61 of file SpamRegexBatch.php.

References $regexes, as, wfRestoreWarnings(), and wfSuppressWarnings().


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