summaryrefslogtreecommitdiff
path: root/plugins/Blacklist
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Blacklist')
-rw-r--r--plugins/Blacklist/BlacklistPlugin.php4
-rw-r--r--plugins/Blacklist/Homepage_blacklist.php4
-rw-r--r--plugins/Blacklist/Nickname_blacklist.php4
-rw-r--r--plugins/Blacklist/blacklistadminpanel.php29
4 files changed, 20 insertions, 21 deletions
diff --git a/plugins/Blacklist/BlacklistPlugin.php b/plugins/Blacklist/BlacklistPlugin.php
index adc4d9d7e..63bffe2c6 100644
--- a/plugins/Blacklist/BlacklistPlugin.php
+++ b/plugins/Blacklist/BlacklistPlugin.php
@@ -262,7 +262,7 @@ class BlacklistPlugin extends Plugin
$patterns = $this->_getUrlPatterns();
foreach ($patterns as $pattern) {
- if (preg_match("/$pattern/", $url)) {
+ if ($pattern != '' && preg_match("/$pattern/", $url)) {
return false;
}
}
@@ -285,7 +285,7 @@ class BlacklistPlugin extends Plugin
$patterns = $this->_getNicknamePatterns();
foreach ($patterns as $pattern) {
- if (preg_match("/$pattern/", $nickname)) {
+ if ($pattern != '' && preg_match("/$pattern/", $nickname)) {
return false;
}
}
diff --git a/plugins/Blacklist/Homepage_blacklist.php b/plugins/Blacklist/Homepage_blacklist.php
index 32080667e..ec89ee4bd 100644
--- a/plugins/Blacklist/Homepage_blacklist.php
+++ b/plugins/Blacklist/Homepage_blacklist.php
@@ -94,7 +94,7 @@ class Homepage_blacklist extends Memcached_DataObject
function keys()
{
- return array('pattern' => 'K');
+ return array_keys($this->keyTypes());
}
/**
@@ -108,7 +108,7 @@ class Homepage_blacklist extends Memcached_DataObject
function keyTypes()
{
- return $this->keys();
+ return array('pattern' => 'K');
}
/**
diff --git a/plugins/Blacklist/Nickname_blacklist.php b/plugins/Blacklist/Nickname_blacklist.php
index 981063144..e8545292d 100644
--- a/plugins/Blacklist/Nickname_blacklist.php
+++ b/plugins/Blacklist/Nickname_blacklist.php
@@ -88,7 +88,7 @@ class Nickname_blacklist extends Memcached_DataObject
function keys()
{
- return array('pattern' => 'K');
+ return array_keys($this->keyTypes());
}
/**
@@ -99,7 +99,7 @@ class Nickname_blacklist extends Memcached_DataObject
function keyTypes()
{
- return $this->keys();
+ return array('pattern' => 'K');
}
/**
diff --git a/plugins/Blacklist/blacklistadminpanel.php b/plugins/Blacklist/blacklistadminpanel.php
index b996aba8d..4289dec1b 100644
--- a/plugins/Blacklist/blacklistadminpanel.php
+++ b/plugins/Blacklist/blacklistadminpanel.php
@@ -88,28 +88,27 @@ class BlacklistadminpanelAction extends AdminPanelAction
function saveSettings()
{
- $nickPatterns = array();
-
- $rawNickPatterns = explode("\n", $this->trimmed('blacklist-nicknames'));
-
- foreach ($rawNickPatterns as $raw) {
- $nickPatterns[] = trim($raw);
- }
-
+ $nickPatterns = $this->splitPatterns($this->trimmed('blacklist-nicknames'));
Nickname_blacklist::saveNew($nickPatterns);
- $rawUrlPatterns = explode("\n", $this->trimmed('blacklist-urls'));
- $urlPatterns = array();
-
- foreach ($rawUrlPatterns as $raw) {
- $urlPatterns[] = trim($raw);
- }
-
+ $urlPatterns = $this->splitPatterns($this->trimmed('blacklist-urls'));
Homepage_blacklist::saveNew($urlPatterns);
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
*