summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Blacklist/BlacklistPlugin.php36
-rw-r--r--plugins/OStatus/OStatusPlugin.php3
-rw-r--r--plugins/OStatus/classes/Magicsig.php34
-rw-r--r--plugins/OStatus/lib/magicenvelope.php6
4 files changed, 39 insertions, 40 deletions
diff --git a/plugins/Blacklist/BlacklistPlugin.php b/plugins/Blacklist/BlacklistPlugin.php
index a7d0942da..adc4d9d7e 100644
--- a/plugins/Blacklist/BlacklistPlugin.php
+++ b/plugins/Blacklist/BlacklistPlugin.php
@@ -49,32 +49,26 @@ class BlacklistPlugin extends Plugin
public $urls = array();
public $canAdmin = true;
- private $_nicknamePatterns = array();
- private $_urlPatterns = array();
-
- /**
- * Initialize the plugin
- *
- * @return void
- */
-
- function initialize()
+ function _getNicknamePatterns()
{
$confNicknames = $this->_configArray('blacklist', 'nicknames');
$dbNicknames = Nickname_blacklist::getPatterns();
- $this->_nicknamePatterns = array_merge($this->nicknames,
- $confNicknames,
- $dbNicknames);
+ return array_merge($this->nicknames,
+ $confNicknames,
+ $dbNicknames);
+ }
+ function _getUrlPatterns()
+ {
$confURLs = $this->_configArray('blacklist', 'urls');
$dbURLs = Homepage_blacklist::getPatterns();
- $this->_urlPatterns = array_merge($this->urls,
- $confURLs,
- $dbURLs);
+ return array_merge($this->urls,
+ $confURLs,
+ $dbURLs);
}
/**
@@ -265,8 +259,9 @@ class BlacklistPlugin extends Plugin
private function _checkUrl($url)
{
- foreach ($this->_urlPatterns as $pattern) {
- common_debug("Checking $url against $pattern");
+ $patterns = $this->_getUrlPatterns();
+
+ foreach ($patterns as $pattern) {
if (preg_match("/$pattern/", $url)) {
return false;
}
@@ -287,8 +282,9 @@ class BlacklistPlugin extends Plugin
private function _checkNickname($nickname)
{
- foreach ($this->_nicknamePatterns as $pattern) {
- common_debug("Checking $nickname against $pattern");
+ $patterns = $this->_getNicknamePatterns();
+
+ foreach ($patterns as $pattern) {
if (preg_match("/$pattern/", $nickname)) {
return false;
}
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index c985fb4bc..f183bc7ae 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -102,7 +102,8 @@ class OStatusPlugin extends Plugin
*/
function onStartEnqueueNotice($notice, &$transports)
{
- $transports[] = 'ostatus';
+ // put our transport first, in case there's any conflict (like OMB)
+ array_unshift($transports, 'ostatus');
return true;
}
diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php
index 864fef628..f8c56a05f 100644
--- a/plugins/OStatus/classes/Magicsig.php
+++ b/plugins/OStatus/classes/Magicsig.php
@@ -129,11 +129,11 @@ class Magicsig extends Memcached_DataObject
public function toString($full_pair = true)
{
- $mod = base64_url_encode($this->publicKey->modulus->toBytes());
- $exp = base64_url_encode($this->publicKey->exponent->toBytes());
+ $mod = Magicsig::base64_url_encode($this->publicKey->modulus->toBytes());
+ $exp = Magicsig::base64_url_encode($this->publicKey->exponent->toBytes());
$private_exp = '';
if ($full_pair && $this->privateKey->exponent->toBytes()) {
- $private_exp = '.' . base64_url_encode($this->privateKey->exponent->toBytes());
+ $private_exp = '.' . Magicsig::base64_url_encode($this->privateKey->exponent->toBytes());
}
return 'RSA.' . $mod . '.' . $exp . $private_exp;
@@ -174,9 +174,9 @@ class Magicsig extends Memcached_DataObject
$rsa = new Crypt_RSA();
$rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1;
$rsa->setHash('sha256');
- $rsa->modulus = new Math_BigInteger(base64_url_decode($mod), 256);
+ $rsa->modulus = new Math_BigInteger(Magicsig::base64_url_decode($mod), 256);
$rsa->k = strlen($rsa->modulus->toBytes());
- $rsa->exponent = new Math_BigInteger(base64_url_decode($exp), 256);
+ $rsa->exponent = new Math_BigInteger(Magicsig::base64_url_decode($exp), 256);
if ($type == 'private') {
$this->privateKey = $rsa;
@@ -203,23 +203,25 @@ class Magicsig extends Memcached_DataObject
public function sign($bytes)
{
$sig = $this->privateKey->sign($bytes);
- return base64_url_encode($sig);
+ return Magicsig::base64_url_encode($sig);
}
public function verify($signed_bytes, $signature)
{
- $signature = base64_url_decode($signature);
+ $signature = Magicsig::base64_url_decode($signature);
return $this->publicKey->verify($signed_bytes, $signature);
}
-
-}
-function base64_url_encode($input)
-{
- return strtr(base64_encode($input), '+/', '-_');
-}
-function base64_url_decode($input)
-{
- return base64_decode(strtr($input, '-_', '+/'));
+ public static function base64_url_encode($input)
+ {
+ return strtr(base64_encode($input), '+/', '-_');
+ }
+
+ public static function base64_url_decode($input)
+ {
+ return base64_decode(strtr($input, '-_', '+/'));
+ }
}
+
+
diff --git a/plugins/OStatus/lib/magicenvelope.php b/plugins/OStatus/lib/magicenvelope.php
index 799b5e307..f39686b71 100644
--- a/plugins/OStatus/lib/magicenvelope.php
+++ b/plugins/OStatus/lib/magicenvelope.php
@@ -83,7 +83,7 @@ class MagicEnvelope
public function signMessage($text, $mimetype, $keypair)
{
$signature_alg = Magicsig::fromString($keypair);
- $armored_text = base64_url_encode($text);
+ $armored_text = Magicsig::base64_url_encode($text);
return array(
'data' => $armored_text,
@@ -121,7 +121,7 @@ class MagicEnvelope
public function unfold($env)
{
$dom = new DOMDocument();
- $dom->loadXML(base64_url_decode($env['data']));
+ $dom->loadXML(Magicsig::base64_url_decode($env['data']));
if ($dom->documentElement->tagName != 'entry') {
return false;
@@ -178,7 +178,7 @@ class MagicEnvelope
return false;
}
- $text = base64_url_decode($env['data']);
+ $text = Magicsig::base64_url_decode($env['data']);
$signer_uri = $this->getAuthor($text);
try {