/** * Some very basic normalization checks * * @covers AntiSpoof::checkUnicodeString * @dataProvider providePositives */ public function testCheckUnicodeString($userName, $spooferName) { $a = AntiSpoof::checkUnicodeString($userName); $b = AntiSpoof::checkUnicodeString($spooferName); $this->assertEquals('OK', $a[0]); $this->assertEquals('OK', $b[0]); $this->assertEquals($a[1], $b[1]); }
/** * @param $name string */ public function __construct($name) { $this->mName = strval($name); list($ok, $normalized) = AntiSpoof::checkUnicodeString($this->mName); $this->mLegal = $ok == 'OK'; if ($this->mLegal) { $this->mNormalized = $normalized; $this->mError = null; } else { $this->mNormalized = null; $this->mError = $normalized; } }
/** * Check whether a user can perform the specified action * on the specified Title * * @param $title string to check * @param $action %Action to check * @return bool TRUE if the the regex matches the title, and is not overridden * else false if it doesn't match (or was overridden) */ public function matches($title, $action) { if (!$title) { return false; } if ($action == 'new-account' && !$this->filtersNewAccounts()) { return false; } if (isset($this->mParams['antispoof']) && is_callable('AntiSpoof::checkUnicodeString')) { list($ok, $norm) = AntiSpoof::checkUnicodeString($title); if ($ok == "OK") { list($ver, $title) = explode(':', $norm, 2); } else { wfDebugLog('TitleBlacklist', 'AntiSpoof could not normalize "' . $title . '".'); } } wfSuppressWarnings(); $match = preg_match("/^(?:{$this->mRegex})\$/us" . (isset($this->mParams['casesensitive']) ? '' : 'i'), $title); wfRestoreWarnings(); if ($match) { if (isset($this->mParams['moveonly']) && $action != 'move') { return false; } if (isset($this->mParams['newaccountonly']) && $action != 'new-account') { return false; } if (!isset($this->mParams['noedit']) && $action == 'edit') { return false; } if (isset($this->mParams['reupload']) && $action == 'upload') { // Special:Upload also checks 'create' permissions when not reuploading return false; } return true; } return false; }
static function initEquivSet() { if (is_null(self::$equivset)) { self::$equivset = unserialize(file_get_contents(__DIR__ . '/equivset.ser')); } }
static function initEquivSet() { if (is_null(self::$equivset)) { self::$equivset = unserialize(file_get_contents(dirname(__FILE__) . '/equivset.ser')); } }