mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 15:30:42 +00:00
Use Equivset library intead of AntiSpoof
Use the new equivset library instead of AntiSpoof. Bug: T175413 Change-Id: I439387deeba99543e194c210953ac73ff98bc5b7 Depends-On: I977d3498b2084a426e2ab4d85c000d1b9dcfe824
This commit is contained in:
parent
83d67e4a12
commit
5335b6c811
|
@ -16,5 +16,4 @@
|
|||
<file>.</file>
|
||||
<arg name="extensions" value="php,php5,inc"/>
|
||||
<arg name="encoding" value="UTF-8"/>
|
||||
<exclude-pattern type="relative">^extensions</exclude-pattern>
|
||||
</ruleset>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"license": "GPL-2.0+",
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"composer/installers": "1.*,>=1.0.1"
|
||||
"wikimedia/equivset": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"jakub-onderka/php-parallel-lint": "0.9.2",
|
||||
|
@ -16,7 +16,7 @@
|
|||
"scripts": {
|
||||
"fix": "phpcbf",
|
||||
"test": [
|
||||
"parallel-lint . --exclude extensions --exclude node_modules --exclude vendor",
|
||||
"parallel-lint . --exclude node_modules --exclude vendor",
|
||||
"phpcs -p -s"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Wikimedia\Equivset\Equivset;
|
||||
|
||||
class AbuseFilterParser {
|
||||
public $mCode, $mTokens, $mPos, $mCur, $mShortCircuit, $mAllowShort, $mLen;
|
||||
|
||||
|
@ -54,6 +56,11 @@ class AbuseFilterParser {
|
|||
|
||||
public static $funcCache = [];
|
||||
|
||||
/**
|
||||
* @var Equivset
|
||||
*/
|
||||
protected static $equivset;
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*
|
||||
|
@ -1154,17 +1161,13 @@ class AbuseFilterParser {
|
|||
* @return mixed
|
||||
*/
|
||||
protected static function ccnorm( $s ) {
|
||||
if ( is_callable( 'AntiSpoof::normalizeString' ) ) {
|
||||
$s = AntiSpoof::normalizeString( $s );
|
||||
} else {
|
||||
// AntiSpoof isn't available, so ignore and return same string
|
||||
wfDebugLog(
|
||||
'AbuseFilter',
|
||||
"Can't compute normalized string (ccnorm) as the AntiSpoof Extension isn't installed."
|
||||
);
|
||||
// Instatiate a single version of the equivset so the data is not loaded
|
||||
// more than once.
|
||||
if ( !self::$equivset ) {
|
||||
self::$equivset = new Equivset();
|
||||
}
|
||||
|
||||
return $s;
|
||||
return self::$equivset->normalize( $s );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,11 +55,6 @@ class AbuseFilterParserTest extends MediaWikiTestCase {
|
|||
* @dataProvider readTests
|
||||
*/
|
||||
public function testParser( $testName, $rule, $expected ) {
|
||||
if ( !class_exists( 'AntiSpoof' ) && preg_match( '/(?:cc)?norm(?:\(|_)/i', $rule ) ) {
|
||||
// The norm and ccnorm parser functions aren't working correctly without AntiSpoof
|
||||
$this->markTestSkipped( 'Parser test ' . $testName . ' requires the AntiSpoof extension' );
|
||||
}
|
||||
|
||||
foreach ( self::getParsers() as $parser ) {
|
||||
$actual = $parser->parse( $rule );
|
||||
$this->assertEquals( $expected, $actual, 'Running parser test ' . $testName );
|
||||
|
|
Loading…
Reference in a new issue