Skip to content

Commit

Permalink
Read whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 committed May 30, 2024
1 parent 6285f83 commit 2ae373d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "UnifiedExtensionForFemiwiki",
"version": "4.1.2",
"version": "4.2.0",
"author": "[https://femiwiki.com/ Femiwiki Team]",
"url": "https://github.com/femiwiki/unifiedExtensionForFemiwiki",
"descriptionmsg": "unifiedextensionforfemiwiki-desc",
Expand Down Expand Up @@ -37,7 +37,12 @@
},
"SpamEmail": {
"class": "MediaWiki\\Extension\\UnifiedExtensionForFemiwiki\\HookHandlers\\SpamEmail",
"services": ["MainConfig", "DBLoadBalancer", "DatabaseBlockStore", "MainWANObjectCache"]
"services": [
"MainConfig",
"DBLoadBalancer",
"DatabaseBlockStore",
"MainWANObjectCache"
]
}
},
"Hooks": {
Expand Down
12 changes: 12 additions & 0 deletions includes/HookHandlers/SpamEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ public function onIsValidEmailAddr( $addr, &$result ) {
return true;
}

$allowlists = BaseBlacklist::getEmailBlacklist()->getWhitelists();
if ( is_array( $allowlists ) ) {
foreach ( $allowlists as $regex ) {
AtEase::suppressWarnings();
$match = preg_match( $regex, $email );
AtEase::restoreWarnings();
if ( $match ) {
return true;
}
}
}

// Check againt MediaWiki:Email-blacklist
$denylist = BaseBlacklist::getEmailBlacklist()->getBlacklists();
foreach ( $denylist as $regex ) {
Expand Down

0 comments on commit 2ae373d

Please sign in to comment.