mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-12 08:49:28 +00:00
3c3a521fec
This should fix every error with excluded rules, leaving only the one for $wgTitle. A double check would be nice in order to avoid regressions due to stupid mistakes. Bug: T178007 Change-Id: I22c179f3a01d652640304b59e43fcb5b5a9abac3
57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
|
|
class ApiAbuseFilterCheckSyntax extends ApiBase {
|
|
|
|
/**
|
|
* @see ApiBase::execute
|
|
*/
|
|
public function execute() {
|
|
// "Anti-DoS"
|
|
if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
|
|
$this->dieWithError( 'apierror-abusefilter-cantcheck', 'permissiondenied' );
|
|
}
|
|
|
|
$params = $this->extractRequestParams();
|
|
$result = AbuseFilter::checkSyntax( $params[ 'filter' ] );
|
|
|
|
$r = [];
|
|
if ( $result === true ) {
|
|
// Everything went better than expected :)
|
|
$r['status'] = 'ok';
|
|
} else {
|
|
$r = [
|
|
'status' => 'error',
|
|
'message' => $result[0],
|
|
'character' => $result[1],
|
|
];
|
|
}
|
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $r );
|
|
}
|
|
|
|
/**
|
|
* @see ApiBase::getAllowedParams
|
|
* @return array
|
|
*/
|
|
public function getAllowedParams() {
|
|
return [
|
|
'filter' => [
|
|
ApiBase::PARAM_REQUIRED => true,
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @see ApiBase::getExamplesMessages()
|
|
* @return array
|
|
*/
|
|
protected function getExamplesMessages() {
|
|
return [
|
|
'action=abusefilterchecksyntax&filter="foo"'
|
|
=> 'apihelp-abusefilterchecksyntax-example-1',
|
|
'action=abusefilterchecksyntax&filter="bar"%20bad_variable'
|
|
=> 'apihelp-abusefilterchecksyntax-example-2',
|
|
];
|
|
}
|
|
}
|