summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib/magicenvelope.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/OStatus/lib/magicenvelope.php')
-rw-r--r--plugins/OStatus/lib/magicenvelope.php21
1 files changed, 13 insertions, 8 deletions
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;
}