Minor improvements to blocked domain filtering

See I3df949c4d41ce

Follows-Up: I3df949c4d41ce65bb4afa013da9c691ac05fc760
Change-Id: I81974a8d935838e00b4155454f2fb619f8a6bad9
This commit is contained in:
Amir Sarabadani 2023-05-31 21:43:07 +02:00
parent 3b5356f664
commit adae5b95b5

View file

@ -11,6 +11,7 @@ use MediaWiki\Extension\AbuseFilter\BlockedDomainStorage;
use MediaWiki\Extension\AbuseFilter\EditRevUpdater;
use MediaWiki\Extension\AbuseFilter\FilterRunnerFactory;
use MediaWiki\Extension\AbuseFilter\VariableGenerator\VariableGeneratorFactory;
use MediaWiki\Extension\AbuseFilter\Variables\UnsetVariableException;
use MediaWiki\Extension\AbuseFilter\Variables\VariableHolder;
use MediaWiki\Extension\AbuseFilter\Variables\VariablesManager;
use MediaWiki\Hook\EditFilterMergedContentHook;
@ -161,13 +162,12 @@ class FilteredActionsHandler implements
return $filterResult;
}
$this->editRevUpdater->setLastEditPage( $page );
$blockedDomainFilterResult = $this->blockedDomainFilter( $vars );
if ( $blockedDomainFilterResult instanceof Status ) {
return $blockedDomainFilterResult;
}
$this->editRevUpdater->setLastEditPage( $page );
return Status::newGood();
}
@ -180,7 +180,12 @@ class FilteredActionsHandler implements
if ( !$wgAbuseFilterEnableBlockedExternalDomain ) {
return false;
}
$urls = $this->variablesManager->getVar( $vars, 'added_links', VariablesManager::GET_LAX );
try {
$urls = $this->variablesManager->getVar( $vars, 'added_links', VariablesManager::GET_STRICT );
} catch ( UnsetVariableException $_ ) {
return false;
}
$addedDomains = [];
foreach ( $urls->toArray() as $addedUrl ) {
$parsedUrl = $this->urlUtils->parse( (string)$addedUrl->getData() );