From d3fc8e22193a86fc71ba21462db89c30fa2abc4b Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 26 Feb 2010 14:47:38 -0800 Subject: Pull conversation URL from Conversation instead of assuming it's local --- lib/noticelist.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/noticelist.php b/lib/noticelist.php index 7d1d2828f..88a925241 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -541,18 +541,39 @@ class NoticeListItem extends Widget { $hasConversation = false; if (!empty($this->notice->conversation)) { - $conversation = Notice::conversationStream($this->notice->conversation, 1, 1); + $conversation = Notice::conversationStream( + $this->notice->conversation, + 1, + 1 + ); if ($conversation->N > 0) { $hasConversation = true; } } if ($hasConversation) { - $this->out->text(' '); - $convurl = common_local_url('conversation', - array('id' => $this->notice->conversation)); - $this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id, - 'class' => 'response'), - _('in context')); + $conv = Conversation::staticGet( + 'id', + $this->notice->conversation + ); + $convurl = $conv->uri; + if (!empty($convurl)) { + $this->out->text(' '); + $this->out->element( + 'a', + array( + 'href' => $convurl.'#notice-'.$this->notice->id, + 'class' => 'response'), + _('in context') + ); + } else { + $msg = sprintf( + "Couldn't find Conversation ID %d to make 'in context'" + . "link for Notice ID %d", + $this->notice->conversation, + $this->notice->id + ); + common_log(LOG_WARNING, $msg); + } } } -- cgit v1.2.3-54-g00ecf From 21edb98a32cf67b9f754c9a74414f113cb71cb37 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 26 Feb 2010 18:26:52 -0500 Subject: change function name --- plugins/OStatus/classes/Magicsig.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php index 30da63c36..7a804a47a 100644 --- a/plugins/OStatus/classes/Magicsig.php +++ b/plugins/OStatus/classes/Magicsig.php @@ -33,20 +33,20 @@ class Magicsig extends Memcached_DataObject { const PUBLICKEYREL = 'magic-public-key'; - + public $__table = 'magicsig'; public $user_id; public $keypair; public $alg; - + private $_rsa; public function __construct($alg = 'RSA-SHA256') { $this->alg = $alg; } - + public /*static*/ function staticGet($k, $v=null) { $obj = parent::staticGet(__CLASS__, $k, $v); @@ -57,7 +57,6 @@ class Magicsig extends Memcached_DataObject return $obj; } - function table() { return array( @@ -77,7 +76,6 @@ class Magicsig extends Memcached_DataObject 64, false)); } - function keys() { return array_keys($this->keyTypes()); @@ -114,7 +112,6 @@ class Magicsig extends Memcached_DataObject $this->insert(); } - public function toString($full_pair = true) { $public_key = $this->_rsa->_public_key; @@ -127,15 +124,15 @@ class Magicsig extends Memcached_DataObject $private_exp = '.' . base64_url_encode($private_key->getExponent()); } - return 'RSA.' . $mod . '.' . $exp . $private_exp; + return 'RSA.' . $mod . '.' . $exp . $private_exp; } - + public static function fromString($text) { PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $magic_sig = new Magicsig(); - + // remove whitespace $text = preg_replace('/\s+/', '', $text); @@ -143,7 +140,7 @@ class Magicsig extends Memcached_DataObject if (!preg_match('/RSA\.([^\.]+)\.([^\.]+)(.([^\.]+))?/', $text, $matches)) { return false; } - + $mod = base64_url_decode($matches[1]); $exp = base64_url_decode($matches[2]); if ($matches[4]) { @@ -185,10 +182,10 @@ class Magicsig extends Memcached_DataObject } } - + public function sign($bytes) { - $sig = $this->_rsa->createSign($bytes, null, 'sha256'); + $sig = $this->_rsa->createSign($bytes, null, 'magicsig_sha256'); if ($this->_rsa->isError()) { $error = $this->_rsa->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -200,7 +197,7 @@ class Magicsig extends Memcached_DataObject public function verify($signed_bytes, $signature) { - $result = $this->_rsa->validateSign($signed_bytes, $signature, null, 'sha256'); + $result = $this->_rsa->validateSign($signed_bytes, $signature, null, 'magicsig_sha256'); if ($this->_rsa->isError()) { $error = $this->keypair->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -208,12 +205,12 @@ class Magicsig extends Memcached_DataObject } return $result; } - + } // Define a sha256 function for hashing // (Crypt_RSA should really be updated to use hash() ) -function sha256($bytes) +function magicsig_sha256($bytes) { return hash('sha256', $bytes); } -- cgit v1.2.3-54-g00ecf From 831eb0d2b6e35073992106a792f2878bb98e6aa4 Mon Sep 17 00:00:00 2001 From: James Walker Date: Fri, 26 Feb 2010 18:22:08 -0500 Subject: renaming sha256 to prevent conflict --- plugins/OStatus/classes/Magicsig.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php index 30da63c36..96900d876 100644 --- a/plugins/OStatus/classes/Magicsig.php +++ b/plugins/OStatus/classes/Magicsig.php @@ -181,14 +181,15 @@ class Magicsig extends Memcached_DataObject switch ($this->alg) { case 'RSA-SHA256': - return 'sha256'; + return 'magicsig_sha256'; } } public function sign($bytes) { - $sig = $this->_rsa->createSign($bytes, null, 'sha256'); + $hash = $this->getHash(); + $sig = $this->_rsa->createSign($bytes, null, $hash); if ($this->_rsa->isError()) { $error = $this->_rsa->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -200,7 +201,8 @@ class Magicsig extends Memcached_DataObject public function verify($signed_bytes, $signature) { - $result = $this->_rsa->validateSign($signed_bytes, $signature, null, 'sha256'); + $hash = $this->getHash(); + $result = $this->_rsa->validateSign($signed_bytes, $signature, null, $hash); if ($this->_rsa->isError()) { $error = $this->keypair->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -213,7 +215,7 @@ class Magicsig extends Memcached_DataObject // Define a sha256 function for hashing // (Crypt_RSA should really be updated to use hash() ) -function sha256($bytes) +function magicsig_sha256($bytes) { return hash('sha256', $bytes); } -- cgit v1.2.3-54-g00ecf From 2344db1ae5b061ee80b0793f70f072cbee3a18f3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 26 Feb 2010 18:28:33 -0500 Subject: Revert "change function name" This reverts commit 21edb98a32cf67b9f754c9a74414f113cb71cb37. --- plugins/OStatus/classes/Magicsig.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/OStatus/classes/Magicsig.php b/plugins/OStatus/classes/Magicsig.php index 7a804a47a..30da63c36 100644 --- a/plugins/OStatus/classes/Magicsig.php +++ b/plugins/OStatus/classes/Magicsig.php @@ -33,20 +33,20 @@ class Magicsig extends Memcached_DataObject { const PUBLICKEYREL = 'magic-public-key'; - + public $__table = 'magicsig'; public $user_id; public $keypair; public $alg; - + private $_rsa; public function __construct($alg = 'RSA-SHA256') { $this->alg = $alg; } - + public /*static*/ function staticGet($k, $v=null) { $obj = parent::staticGet(__CLASS__, $k, $v); @@ -57,6 +57,7 @@ class Magicsig extends Memcached_DataObject return $obj; } + function table() { return array( @@ -76,6 +77,7 @@ class Magicsig extends Memcached_DataObject 64, false)); } + function keys() { return array_keys($this->keyTypes()); @@ -112,6 +114,7 @@ class Magicsig extends Memcached_DataObject $this->insert(); } + public function toString($full_pair = true) { $public_key = $this->_rsa->_public_key; @@ -124,15 +127,15 @@ class Magicsig extends Memcached_DataObject $private_exp = '.' . base64_url_encode($private_key->getExponent()); } - return 'RSA.' . $mod . '.' . $exp . $private_exp; + return 'RSA.' . $mod . '.' . $exp . $private_exp; } - + public static function fromString($text) { PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $magic_sig = new Magicsig(); - + // remove whitespace $text = preg_replace('/\s+/', '', $text); @@ -140,7 +143,7 @@ class Magicsig extends Memcached_DataObject if (!preg_match('/RSA\.([^\.]+)\.([^\.]+)(.([^\.]+))?/', $text, $matches)) { return false; } - + $mod = base64_url_decode($matches[1]); $exp = base64_url_decode($matches[2]); if ($matches[4]) { @@ -182,10 +185,10 @@ class Magicsig extends Memcached_DataObject } } - + public function sign($bytes) { - $sig = $this->_rsa->createSign($bytes, null, 'magicsig_sha256'); + $sig = $this->_rsa->createSign($bytes, null, 'sha256'); if ($this->_rsa->isError()) { $error = $this->_rsa->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -197,7 +200,7 @@ class Magicsig extends Memcached_DataObject public function verify($signed_bytes, $signature) { - $result = $this->_rsa->validateSign($signed_bytes, $signature, null, 'magicsig_sha256'); + $result = $this->_rsa->validateSign($signed_bytes, $signature, null, 'sha256'); if ($this->_rsa->isError()) { $error = $this->keypair->getLastError(); common_log(LOG_DEBUG, 'RSA Error: '. $error->getMessage()); @@ -205,12 +208,12 @@ class Magicsig extends Memcached_DataObject } return $result; } - + } // Define a sha256 function for hashing // (Crypt_RSA should really be updated to use hash() ) -function magicsig_sha256($bytes) +function sha256($bytes) { return hash('sha256', $bytes); } -- cgit v1.2.3-54-g00ecf