summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2010-03-11 16:39:07 -0500
committerSarven Capadisli <csarven@status.net>2010-03-11 16:39:07 -0500
commit4c320872d92e4323c2566013034dbea45b309065 (patch)
treebc024cf3a925d84de58180af3d2c0c15dd35e166
parentc6f09306b1c72296db8b55500a5d6a2ea8cd5dd2 (diff)
parent512e51105372daf9c85af9284de1463084f03aa9 (diff)
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
-rw-r--r--classes/Profile.php12
-rw-r--r--classes/User.php9
-rw-r--r--plugins/OStatus/lib/magicenvelope.php21
-rw-r--r--plugins/OStatus/lib/xrdaction.php2
4 files changed, 28 insertions, 16 deletions
diff --git a/classes/Profile.php b/classes/Profile.php
index 0322c9358..91f6e4692 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -147,14 +147,16 @@ class Profile extends Memcached_DataObject
return ($this->fullname) ? $this->fullname : $this->nickname;
}
- # Get latest notice on or before date; default now
- function getCurrentNotice($dt=null)
+ /**
+ * Get the most recent notice posted by this user, if any.
+ *
+ * @return mixed Notice or null
+ */
+ function getCurrentNotice()
{
$notice = new Notice();
$notice->profile_id = $this->id;
- if ($dt) {
- $notice->whereAdd('created < "' . $dt . '"');
- }
+ // @fixme change this to sort on notice.id only when indexes are updated
$notice->orderBy('created DESC, notice.id DESC');
$notice->limit(1);
if ($notice->find(true)) {
diff --git a/classes/User.php b/classes/User.php
index fade0f35d..77091fad5 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -132,13 +132,18 @@ class User extends Memcached_DataObject
return !in_array($nickname, $blacklist);
}
- function getCurrentNotice($dt=null)
+ /**
+ * Get the most recent notice posted by this user, if any.
+ *
+ * @return mixed Notice or null
+ */
+ function getCurrentNotice()
{
$profile = $this->getProfile();
if (!$profile) {
return null;
}
- return $profile->getCurrentNotice($dt);
+ return $profile->getCurrentNotice();
}
function getCarrier()
diff --git a/plugins/OStatus/lib/magicenvelope.php b/plugins/OStatus/lib/magicenvelope.php
index fb8c57c71..9266cab5c 100644
--- a/plugins/OStatus/lib/magicenvelope.php
+++ b/plugins/OStatus/lib/magicenvelope.php
@@ -59,7 +59,11 @@ class MagicEnvelope
}
if ($xrd->links) {
if ($link = Discovery::getService($xrd->links, Magicsig::PUBLICKEYREL)) {
- list($type, $keypair) = explode(';', $link['href']);
+ list($type, $keypair) = explode(',', $link['href']);
+ if (empty($keypair)) {
+ // Backwards compatibility check for separator bug in 0.9.0
+ list($type, $keypair) = explode(';', $link['href']);
+ }
return $keypair;
}
}
@@ -70,7 +74,7 @@ class MagicEnvelope
public function signMessage($text, $mimetype, $keypair)
{
$signature_alg = Magicsig::fromString($keypair);
- $armored_text = base64_encode($text);
+ $armored_text = base64_url_encode($text);
return array(
'data' => $armored_text,
@@ -108,7 +112,7 @@ class MagicEnvelope
public function unfold($env)
{
$dom = new DOMDocument();
- $dom->loadXML(base64_decode($env['data']));
+ $dom->loadXML(base64_url_decode($env['data']));
if ($dom->documentElement->tagName != 'entry') {
return false;
@@ -165,7 +169,7 @@ class MagicEnvelope
return false;
}
- $text = base64_decode($env['data']);
+ $text = base64_url_decode($env['data']);
$signer_uri = $this->getAuthor($text);
try {
@@ -193,11 +197,12 @@ class MagicEnvelope
public function fromDom($dom)
{
- if ($dom->documentElement->tagName == 'entry') {
+ $env_element = $dom->getElementsByTagNameNS(MagicEnvelope::NS, 'env')->item(0);
+ if (!$env_element) {
$env_element = $dom->getElementsByTagNameNS(MagicEnvelope::NS, 'provenance')->item(0);
- } else if ($dom->documentElement->tagName == 'me:env') {
- $env_element = $dom->documentElement;
- } else {
+ }
+
+ if (!$env_element) {
return false;
}
diff --git a/plugins/OStatus/lib/xrdaction.php b/plugins/OStatus/lib/xrdaction.php
index 6881292ad..b3c1d8453 100644
--- a/plugins/OStatus/lib/xrdaction.php
+++ b/plugins/OStatus/lib/xrdaction.php
@@ -91,7 +91,7 @@ class XrdAction extends Action
}
$xrd->links[] = array('rel' => Magicsig::PUBLICKEYREL,
- 'href' => 'data:application/magic-public-key;'. $magickey->toString(false));
+ 'href' => 'data:application/magic-public-key,'. $magickey->toString(false));
// TODO - finalize where the redirect should go on the publisher
$url = common_local_url('ostatussub') . '?profile={uri}';