diff options
author | Brion Vibber <brion@pobox.com> | 2010-03-02 15:38:52 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-03-02 15:38:52 -0800 |
commit | 7175e7c7a10222cef0bbf69c06c70464b757e00b (patch) | |
tree | e76423eebdea59f8e28f6b367f1e5b4b9fc8f830 | |
parent | b1ffbf17d3da90f4c509a47c9fd876304ed9e3fc (diff) |
OStatus fix: look for <link>s in the current element's children, not in all its descendants. Was breaking notice URL transfer, pulling a profile link by mistake.
-rw-r--r-- | lib/activity.php | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/activity.php b/lib/activity.php index b20153213..7926d0569 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -344,16 +344,18 @@ class ActivityUtils static function getLink(DOMNode $element, $rel, $type=null) { - $links = $element->getElementsByTagnameNS(self::ATOM, self::LINK); + $els = $element->childNodes; - foreach ($links as $link) { + foreach ($els as $link) { + if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) { - $linkRel = $link->getAttribute(self::REL); - $linkType = $link->getAttribute(self::TYPE); + $linkRel = $link->getAttribute(self::REL); + $linkType = $link->getAttribute(self::TYPE); - if ($linkRel == $rel && - (is_null($type) || $linkType == $type)) { - return $link->getAttribute(self::HREF); + if ($linkRel == $rel && + (is_null($type) || $linkType == $type)) { + return $link->getAttribute(self::HREF); + } } } @@ -362,17 +364,19 @@ class ActivityUtils static function getLinks(DOMNode $element, $rel, $type=null) { - $links = $element->getElementsByTagnameNS(self::ATOM, self::LINK); + $els = $element->childNodes; $out = array(); - foreach ($links as $link) { + foreach ($els as $link) { + if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) { - $linkRel = $link->getAttribute(self::REL); - $linkType = $link->getAttribute(self::TYPE); + $linkRel = $link->getAttribute(self::REL); + $linkType = $link->getAttribute(self::TYPE); - if ($linkRel == $rel && - (is_null($type) || $linkType == $type)) { - $out[] = $link; + if ($linkRel == $rel && + (is_null($type) || $linkType == $type)) { + $out[] = $link; + } } } |