From adae5b95b55489facbc97f8303e7f998414ccc90 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Wed, 31 May 2023 21:43:07 +0200 Subject: [PATCH] Minor improvements to blocked domain filtering See I3df949c4d41ce Follows-Up: I3df949c4d41ce65bb4afa013da9c691ac05fc760 Change-Id: I81974a8d935838e00b4155454f2fb619f8a6bad9 --- includes/Hooks/Handlers/FilteredActionsHandler.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/Hooks/Handlers/FilteredActionsHandler.php b/includes/Hooks/Handlers/FilteredActionsHandler.php index 1a1b2e56a..c0a4ab639 100644 --- a/includes/Hooks/Handlers/FilteredActionsHandler.php +++ b/includes/Hooks/Handlers/FilteredActionsHandler.php @@ -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() );