Fix for Blacklist plugin: was saving an empty entry if blacklist was empty, which would match *all* possible nickname registrations, preventing all registration on mozilla.status.net.
Now saving only non-empty lines, and only matching non-empty lines so we don't fail if we still have a bogus entry.
This commit is contained in:
parent
67b8b1334f
commit
390a2a8624
@ -262,7 +262,7 @@ class BlacklistPlugin extends Plugin
|
|||||||
$patterns = $this->_getUrlPatterns();
|
$patterns = $this->_getUrlPatterns();
|
||||||
|
|
||||||
foreach ($patterns as $pattern) {
|
foreach ($patterns as $pattern) {
|
||||||
if (preg_match("/$pattern/", $url)) {
|
if ($pattern != '' && preg_match("/$pattern/", $url)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ class BlacklistPlugin extends Plugin
|
|||||||
$patterns = $this->_getNicknamePatterns();
|
$patterns = $this->_getNicknamePatterns();
|
||||||
|
|
||||||
foreach ($patterns as $pattern) {
|
foreach ($patterns as $pattern) {
|
||||||
if (preg_match("/$pattern/", $nickname)) {
|
if ($pattern != '' && preg_match("/$pattern/", $nickname)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,28 +88,27 @@ class BlacklistadminpanelAction extends AdminPanelAction
|
|||||||
|
|
||||||
function saveSettings()
|
function saveSettings()
|
||||||
{
|
{
|
||||||
$nickPatterns = array();
|
$nickPatterns = $this->splitPatterns($this->trimmed('blacklist-nicknames'));
|
||||||
|
|
||||||
$rawNickPatterns = explode("\n", $this->trimmed('blacklist-nicknames'));
|
|
||||||
|
|
||||||
foreach ($rawNickPatterns as $raw) {
|
|
||||||
$nickPatterns[] = trim($raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
Nickname_blacklist::saveNew($nickPatterns);
|
Nickname_blacklist::saveNew($nickPatterns);
|
||||||
|
|
||||||
$rawUrlPatterns = explode("\n", $this->trimmed('blacklist-urls'));
|
$urlPatterns = $this->splitPatterns($this->trimmed('url-nicknames'));
|
||||||
$urlPatterns = array();
|
|
||||||
|
|
||||||
foreach ($rawUrlPatterns as $raw) {
|
|
||||||
$urlPatterns[] = trim($raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
Homepage_blacklist::saveNew($urlPatterns);
|
Homepage_blacklist::saveNew($urlPatterns);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function splitPatterns($text)
|
||||||
|
{
|
||||||
|
$patterns = array();
|
||||||
|
foreach (explode("\n", $text) as $raw) {
|
||||||
|
$trimmed = trim($raw);
|
||||||
|
if ($trimmed != '') {
|
||||||
|
$patterns[] = $trimmed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $patterns;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the values
|
* Validate the values
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user