mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
Merge "Blocked Domains: Minor tweaks"
This commit is contained in:
commit
aaa858f822
|
@ -78,7 +78,7 @@ class BlockedDomainFilter {
|
|||
continue;
|
||||
}
|
||||
// Given that we block subdomains of blocked domains too
|
||||
// pretend that all of higher-level domains are added as well
|
||||
// pretend that all the higher-level domains are added as well
|
||||
// so for foo.bar.com, you will have three domains to check:
|
||||
// foo.bar.com, bar.com, and com
|
||||
// This saves string search in the large list of blocked domains
|
||||
|
|
|
@ -28,11 +28,13 @@ use MediaWiki\Content\JsonContent;
|
|||
use MediaWiki\Json\FormatJson;
|
||||
use MediaWiki\Message\Message;
|
||||
use MediaWiki\Page\WikiPageFactory;
|
||||
use MediaWiki\Permissions\Authority;
|
||||
use MediaWiki\Revision\RevisionLookup;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
use MediaWiki\Title\TitleValue;
|
||||
use MediaWiki\User\UserFactory;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use MediaWiki\Utils\UrlUtils;
|
||||
use RecentChange;
|
||||
use StatusValue;
|
||||
|
@ -108,7 +110,7 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
}
|
||||
|
||||
/**
|
||||
* Load the computed domain block list
|
||||
* Load the computed domain blocklist
|
||||
*
|
||||
* @return array<string,true> Flipped for performance reasons
|
||||
*/
|
||||
|
@ -164,7 +166,7 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
/**
|
||||
* Fetch the contents of the configuration page, without caching.
|
||||
*
|
||||
* Result is not validated with a config validator.
|
||||
* The result is not validated with a config validator.
|
||||
*
|
||||
* @param int $flags bit field, see IDBAccessObject::READ_XXX; do NOT pass READ_UNCACHED
|
||||
* @return StatusValue Status object, with the configuration (as JSON data) on success.
|
||||
|
@ -173,7 +175,7 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
$revision = $this->revisionLookup->getRevisionByTitle( $this->getBlockedDomainPage(), 0, $flags );
|
||||
if ( !$revision ) {
|
||||
// The configuration page does not exist. Pretend it does not configure anything
|
||||
// specific (failure mode and empty-page behavior is equal).
|
||||
// specific (failure mode and empty-page behaviors are equal).
|
||||
return StatusValue::newGood( [] );
|
||||
}
|
||||
$content = $revision->getContent( SlotRecord::MAIN );
|
||||
|
@ -191,7 +193,8 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
*
|
||||
* @param string $domain domain to be blocked
|
||||
* @param string $notes User provided notes
|
||||
* @param \MediaWiki\Permissions\Authority|\MediaWiki\User\UserIdentity $user Performer
|
||||
* @param Authority|UserIdentity $user Performer
|
||||
*
|
||||
* @return RevisionRecord|null Null on failure
|
||||
*/
|
||||
public function addDomain( string $domain, string $notes, $user ): ?RevisionRecord {
|
||||
|
@ -211,7 +214,8 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
*
|
||||
* @param string $domain domain to be removed from the blocked list
|
||||
* @param string $notes User provided notes
|
||||
* @param \MediaWiki\Permissions\Authority|\MediaWiki\User\UserIdentity $user Performer
|
||||
* @param Authority|UserIdentity $user Performer
|
||||
*
|
||||
* @return RevisionRecord|null Null on failure
|
||||
*/
|
||||
public function removeDomain( string $domain, string $notes, $user ): ?RevisionRecord {
|
||||
|
@ -255,8 +259,9 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
* Save the provided content into the page
|
||||
*
|
||||
* @param array[] $content To be turned into JSON
|
||||
* @param \MediaWiki\Permissions\Authority|\MediaWiki\User\UserIdentity $user Performer
|
||||
* @param Authority|UserIdentity $user Performer
|
||||
* @param string $comment Save comment
|
||||
*
|
||||
* @return RevisionRecord|null
|
||||
*/
|
||||
private function saveContent( array $content, $user, string $comment ): ?RevisionRecord {
|
||||
|
@ -275,7 +280,7 @@ class BlockedDomainStorage implements IDBAccessObject {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return TitleValue TitleValue of the config json page
|
||||
* @return TitleValue TitleValue of the config JSON page
|
||||
*/
|
||||
private function getBlockedDomainPage(): TitleValue {
|
||||
return new TitleValue( NS_MEDIAWIKI, self::TARGET_PAGE );
|
||||
|
|
|
@ -166,8 +166,7 @@ class BlockedExternalDomains extends SpecialPage {
|
|||
* @return string HTML for the row
|
||||
*/
|
||||
private function doDomainRow( $domain, $showManageActions ) {
|
||||
$newRow = '';
|
||||
$newRow .= Html::rawElement( 'td', [], Html::element( 'code', [], $domain['domain'] ) );
|
||||
$newRow = Html::rawElement( 'td', [], Html::element( 'code', [], $domain['domain'] ) );
|
||||
|
||||
$newRow .= Html::rawElement( 'td', [], $this->getOutput()->parseInlineAsInterface( $domain['notes'] ) );
|
||||
|
||||
|
@ -186,7 +185,8 @@ class BlockedExternalDomains extends SpecialPage {
|
|||
$this->getPageTitle( 'remove' ),
|
||||
$this->msg( 'abusefilter-blocked-domains-remove' )->text(),
|
||||
[],
|
||||
[ 'domain' => $domain['domain'] ] );
|
||||
[ 'domain' => $domain['domain'] ]
|
||||
);
|
||||
$newRow .= Html::rawElement( 'td', [], $actionLink );
|
||||
}
|
||||
|
||||
|
@ -343,6 +343,7 @@ class BlockedExternalDomains extends SpecialPage {
|
|||
return 'spam';
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function isListed() {
|
||||
return $this->getConfig()->get( 'AbuseFilterEnableBlockedExternalDomain' );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue