From 115231f917c9c9c67fe3768310c4852d8e1cada1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 13 Aug 2010 10:51:00 -0700 Subject: Suppress whinging during HTML parsing in profile page discovery for things that turn out to be XML feeds with funny namespaces. --- plugins/OStatus/lib/discoveryhints.php | 5 +++-- plugins/OStatus/lib/feeddiscovery.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/OStatus/lib/discoveryhints.php b/plugins/OStatus/lib/discoveryhints.php index 34c9be277..fa2ead732 100644 --- a/plugins/OStatus/lib/discoveryhints.php +++ b/plugins/OStatus/lib/discoveryhints.php @@ -114,9 +114,10 @@ class DiscoveryHints { static function _hcard($body, $url) { - // DOMDocument::loadHTML may throw warnings on unrecognized elements. + // DOMDocument::loadHTML may throw warnings on unrecognized elements, + // and notices on unrecognized namespaces. - $old = error_reporting(error_reporting() & ~E_WARNING); + $old = error_reporting(error_reporting() & ~(E_WARNING | E_NOTICE)); $doc = new DOMDocument(); $doc->loadHTML($body); diff --git a/plugins/OStatus/lib/feeddiscovery.php b/plugins/OStatus/lib/feeddiscovery.php index a55399d7c..8a166a0be 100644 --- a/plugins/OStatus/lib/feeddiscovery.php +++ b/plugins/OStatus/lib/feeddiscovery.php @@ -196,8 +196,9 @@ class FeedDiscovery */ function discoverFromHTML($url, $body) { - // DOMDocument::loadHTML may throw warnings on unrecognized elements. - $old = error_reporting(error_reporting() & ~E_WARNING); + // DOMDocument::loadHTML may throw warnings on unrecognized elements, + // and notices on unrecognized namespaces. + $old = error_reporting(error_reporting() & ~(E_WARNING | E_NOTICE)); $dom = new DOMDocument(); $ok = $dom->loadHTML($body); error_reporting($old); -- cgit v1.2.3-54-g00ecf From 85693884994bda3067d2b9a46d279fd3a5c1c9f5 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 13 Aug 2010 11:02:21 -0700 Subject: SubMirror: check feel-url discovery if profile-url discovery failed; should help when giving direct feeds to subscribe to --- plugins/SubMirror/actions/basemirror.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/SubMirror/actions/basemirror.php b/plugins/SubMirror/actions/basemirror.php index 5be0699f0..be6942efa 100644 --- a/plugins/SubMirror/actions/basemirror.php +++ b/plugins/SubMirror/actions/basemirror.php @@ -92,7 +92,13 @@ abstract class BaseMirrorAction extends Action */ protected function profileForFeed($url) { - $oprofile = Ostatus_profile::ensureProfileURL($url); + try { + // Maybe we got a web page? + $oprofile = Ostatus_profile::ensureProfileURL($url); + } catch (Exception $e) { + // Direct feed URL? + $oprofile = Ostatus_profile::ensureFeedURL($url); + } if ($oprofile->isGroup()) { $this->clientError(_m("Can't mirror a StatusNet group at this time.")); } -- cgit v1.2.3-54-g00ecf From 185f18024a208e0d981721e492a4ca54263e2520 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 13 Aug 2010 11:41:44 -0700 Subject: Fixes for RSS subscriptions: accept posts with no ActivityStreams object-type set; be more liberal about accepting posts from feeds where the author info doesn't match (we'll post under the feed's profile and just not try to update the profile info). --- plugins/OStatus/classes/Ostatus_profile.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 8f8eb773f..e76683a1c 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -456,8 +456,10 @@ class Ostatus_profile extends Memcached_DataObject case ActivityObject::NOTE: case ActivityObject::STATUS: case ActivityObject::COMMENT: + case null: // Unspecified type is assumed to be a blog post; as we get from RSS. break; default: + common_log(LOG_INFO, "Aborting processing for unrecognized activity type " . $activity->objects[0]->type); throw new ClientException("Can't handle that kind of post."); } @@ -496,8 +498,11 @@ class Ostatus_profile extends Memcached_DataObject } else if ($actor->id) { // We have an ActivityStreams actor with an explicit ID that doesn't match the feed owner. // This isn't what we expect from mainline OStatus person feeds! - // Group feeds go down another path, with different validation. - throw new Exception("Got an actor '{$actor->title}' ({$actor->id}) on single-user feed for {$this->uri}"); + // Group feeds go down another path, with different validation... + // Most likely this is a plain ol' blog feed of some kind which + // doesn't match our expectations. We'll take the entry, but ignore + // the info. + common_log(LOG_WARNING, "Got an actor '{$actor->title}' ({$actor->id}) on single-user feed for {$this->uri}"); } else { // Plain without ActivityStreams actor info. // We'll just ignore this info for now and save the update under the feed's identity. -- cgit v1.2.3-54-g00ecf