From a9dabbe77e8ab575aaf5c3742e2cddb4874e6881 Mon Sep 17 00:00:00 2001 From: James Walker Date: Sat, 13 Mar 2010 10:37:08 -0500 Subject: * wrong param order to in_array * in getContent() if "type" isn't set, assume text (per atom spec) --- lib/activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/activity.php') diff --git a/lib/activity.php b/lib/activity.php index 125d391b0..738200c0b 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -457,7 +457,7 @@ class ActivityUtils // slavishly following http://atompub.org/rfc4287.html#rfc.section.4.1.3.3 - if ($type == 'text') { + if (empty($type) || $type == 'text') { return $contentEl->textContent; } else if ($type == 'html') { $text = $contentEl->textContent; @@ -476,7 +476,7 @@ class ActivityUtils $text .= $doc->saveXML($child); } return trim($text); - } else if (in_array(array('text/xml', 'application/xml'), $type) || + } else if (in_array($type, array('text/xml', 'application/xml')) || preg_match('#(+|/)xml$#', $type)) { throw new ClientException(_("Can't handle embedded XML content yet.")); } else if (strncasecmp($type, 'text/', 5)) { -- cgit v1.2.3-54-g00ecf From c4f89b06f1e7fe969e049c7dfe672bdfd6e5c8f9 Mon Sep 17 00:00:00 2001 From: James Walker Date: Sun, 14 Mar 2010 12:57:24 -0400 Subject: give preference to rel="photo" (per latest ActivityStreams spec), but still support rel="avatar" for compat --- lib/activity.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/activity.php') diff --git a/lib/activity.php b/lib/activity.php index 738200c0b..6acf37a8a 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -681,9 +681,16 @@ class ActivityObject if ($this->type == self::PERSON || $this->type == self::GROUP) { $this->displayName = $this->title; - $avatars = ActivityUtils::getLinks($element, 'avatar'); - foreach ($avatars as $link) { - $this->avatarLinks[] = new AvatarLink($link); + $photos = ActivityUtils::getLinks($element, 'photo'); + if (count($photos)) { + foreach ($photos as $link) { + $this->avatarLinks[] = new AvatarLink($link); + } + } else { + $avatars = ActivityUtils::getLinks($element, 'avatar'); + foreach ($avatars as $link) { + $this->avatarLinks[] = new AvatarLink($link); + } } $this->poco = new PoCo($element); -- cgit v1.2.3-54-g00ecf From c9232d8f26f055a9a1124b4b3db510e80979bf18 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 15 Mar 2010 20:21:55 +0000 Subject: Ticket #2242: fix reading of inline XHTML content in Atom feeds for OStatus input. Lookup of the
needed to check for the XHTML namespace. --- lib/activity.php | 2 +- plugins/OStatus/scripts/testfeed.php | 89 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 plugins/OStatus/scripts/testfeed.php (limited to 'lib/activity.php') diff --git a/lib/activity.php b/lib/activity.php index 6acf37a8a..ae65fe36f 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -463,7 +463,7 @@ class ActivityUtils $text = $contentEl->textContent; return htmlspecialchars_decode($text, ENT_QUOTES); } else if ($type == 'xhtml') { - $divEl = ActivityUtils::child($contentEl, 'div'); + $divEl = ActivityUtils::child($contentEl, 'div', 'http://www.w3.org/1999/xhtml'); if (empty($divEl)) { return null; } diff --git a/plugins/OStatus/scripts/testfeed.php b/plugins/OStatus/scripts/testfeed.php new file mode 100644 index 000000000..5e3ccd433 --- /dev/null +++ b/plugins/OStatus/scripts/testfeed.php @@ -0,0 +1,89 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); + +$longoptions = array('skip=', 'count='); + +$helptext = <<loadXML($xml)) { + print "Bad XML.\n"; + exit(1); +} + +if ($skip || $count) { + $entries = $feed->getElementsByTagNameNS(ActivityUtils::ATOM, 'entry'); + $remove = array(); + for ($i = 0; $i < $skip && $i < $entries->length; $i++) { + $item = $entries->item($i); + if ($item) { + $remove[] = $item; + } + } + if ($count) { + for ($i = $skip + $count; $i < $entries->length; $i++) { + $item = $entries->item($i); + if ($item) { + $remove[] = $item; + } + } + } + foreach ($remove as $item) { + $item->parentNode->removeChild($item); + } +} + +Event::handle('StartFeedSubReceive', array($sub, $feed)); + -- cgit v1.2.3-54-g00ecf From b994d529f4de53df6350e12b5e81889cee17f317 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 15 Mar 2010 19:06:06 -0700 Subject: Throw an exception if we receive a document instead of a feed's root element --- lib/activity.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'lib/activity.php') diff --git a/lib/activity.php b/lib/activity.php index ae65fe36f..d84eabf7c 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -1083,15 +1083,11 @@ class Activity $this->entry = $entry; - // @fixme Don't send in a DOMDocument + // Insist on a feed's root DOMElement; don't allow a DOMDocument if ($feed instanceof DOMDocument) { - common_log( - LOG_WARNING, - 'Activity::__construct() - ' - . 'DOMDocument passed in for feed by mistake. ' - . "Expecting a 'feed' DOMElement." + throw new ClientException( + _("Expecting a root feed element but got a whole XML document.") ); - $feed = $feed->getElementsByTagName('feed')->item(0); } $this->feed = $feed; -- cgit v1.2.3-54-g00ecf