From f7b2bb09e66d3985ce6f524e6841e5f6a473afdc Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 13 Aug 2010 10:51:00 -0700 Subject: [PATCH 1/8] 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(-) diff --git a/plugins/OStatus/lib/discoveryhints.php b/plugins/OStatus/lib/discoveryhints.php index 34c9be2777..fa2ead7320 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 a55399d7c8..8a166a0be5 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); From 60c36c1868f6bed18b2ac71ffb37f09ef1cbc472 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 13 Aug 2010 11:02:21 -0700 Subject: [PATCH 2/8] 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(-) diff --git a/plugins/SubMirror/actions/basemirror.php b/plugins/SubMirror/actions/basemirror.php index 5be0699f09..be6942efa7 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.")); } From 16f75b95c695d4730bed8bdf6b609caa47721e3a Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 13 Aug 2010 11:41:44 -0700 Subject: [PATCH 3/8] 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(-) diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 8f8eb773f8..e76683a1c2 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. From 54b93aede615271dd22983172ffabcd9dbd18bf6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 13 Aug 2010 13:07:25 -0700 Subject: [PATCH 4/8] typo mixing up and in salmonaction --- plugins/OStatus/lib/salmonaction.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/OStatus/lib/salmonaction.php b/plugins/OStatus/lib/salmonaction.php index fa9dc3b1da..9d6c6b269a 100644 --- a/plugins/OStatus/lib/salmonaction.php +++ b/plugins/OStatus/lib/salmonaction.php @@ -47,7 +47,6 @@ class SalmonAction extends Action $xml = file_get_contents('php://input'); - // Check the signature $salmon = new Salmon; if (!$salmon->verifyMagicEnv($xml)) { @@ -58,7 +57,6 @@ class SalmonAction extends Action $env = $magic_env->parse($xml); $xml = $magic_env->unfold($env); } - $dom = DOMDocument::loadXML($xml); if ($dom->documentElement->namespaceURI != Activity::ATOM || @@ -67,7 +65,7 @@ class SalmonAction extends Action $this->clientError(_m('Salmon post must be an Atom entry.')); } - $this->act = new Activity($dom->documentElement); + $this->activity = new Activity($dom->documentElement); return true; } @@ -79,9 +77,9 @@ class SalmonAction extends Action { StatusNet::setApi(true); // Send smaller error pages - common_log(LOG_DEBUG, "Got a " . $this->act->verb); + common_log(LOG_DEBUG, "Got a " . $this->activity->verb); if (Event::handle('StartHandleSalmon', array($this->activity))) { - switch ($this->act->verb) + switch ($this->activity->verb) { case ActivityVerb::POST: $this->handlePost(); @@ -164,12 +162,12 @@ class SalmonAction extends Action */ function handleUpdateProfile() { - $oprofile = Ostatus_profile::getActorProfile($this->act); + $oprofile = Ostatus_profile::getActorProfile($this->activity); if ($oprofile) { common_log(LOG_INFO, "Got a profile-update ping from $oprofile->uri"); - $oprofile->updateFromActivityObject($this->act->actor); + $oprofile->updateFromActivityObject($this->activity->actor); } else { - common_log(LOG_INFO, "Ignoring profile-update ping from unknown " . $this->act->actor->id); + common_log(LOG_INFO, "Ignoring profile-update ping from unknown " . $this->activity->actor->id); } } @@ -178,10 +176,10 @@ class SalmonAction extends Action */ function ensureProfile() { - $actor = $this->act->actor; + $actor = $this->activity->actor; if (empty($actor->id)) { common_log(LOG_ERR, "broken actor: " . var_export($actor, true)); - common_log(LOG_ERR, "activity with no actor: " . var_export($this->act, true)); + common_log(LOG_ERR, "activity with no actor: " . var_export($this->activity, true)); throw new Exception("Received a salmon slap from unidentified actor."); } @@ -191,6 +189,6 @@ class SalmonAction extends Action function saveNotice() { $oprofile = $this->ensureProfile(); - return $oprofile->processPost($this->act, 'salmon'); + return $oprofile->processPost($this->activity, 'salmon'); } } From 5110275a38f68a52114a5f51d661ace730a9428b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 13 Aug 2010 14:18:54 -0700 Subject: [PATCH 5/8] fix use of activity rather than act in salmonaction subclasses, too --- plugins/OStatus/actions/groupsalmon.php | 4 ++-- plugins/OStatus/actions/usersalmon.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/OStatus/actions/groupsalmon.php b/plugins/OStatus/actions/groupsalmon.php index d60725a71b..5094dccf0f 100644 --- a/plugins/OStatus/actions/groupsalmon.php +++ b/plugins/OStatus/actions/groupsalmon.php @@ -61,7 +61,7 @@ class GroupsalmonAction extends SalmonAction function handlePost() { // @fixme process all objects? - switch ($this->act->objects[0]->type) { + switch ($this->activity->objects[0]->type) { case ActivityObject::ARTICLE: case ActivityObject::BLOGENTRY: case ActivityObject::NOTE: @@ -74,7 +74,7 @@ class GroupsalmonAction extends SalmonAction // Notice must be to the attention of this group - $context = $this->act->context; + $context = $this->activity->context; if (empty($context->attention)) { throw new ClientException("Not to the attention of anyone."); diff --git a/plugins/OStatus/actions/usersalmon.php b/plugins/OStatus/actions/usersalmon.php index 6c360c49f9..641e131abc 100644 --- a/plugins/OStatus/actions/usersalmon.php +++ b/plugins/OStatus/actions/usersalmon.php @@ -55,10 +55,10 @@ class UsersalmonAction extends SalmonAction */ function handlePost() { - common_log(LOG_INFO, "Received post of '{$this->act->objects[0]->id}' from '{$this->act->actor->id}'"); + common_log(LOG_INFO, "Received post of '{$this->activity->objects[0]->id}' from '{$this->activity->actor->id}'"); // @fixme: process all activity objects? - switch ($this->act->objects[0]->type) { + switch ($this->activity->objects[0]->type) { case ActivityObject::ARTICLE: case ActivityObject::BLOGENTRY: case ActivityObject::NOTE: @@ -72,7 +72,7 @@ class UsersalmonAction extends SalmonAction // Notice must either be a) in reply to a notice by this user // or b) to the attention of this user - $context = $this->act->context; + $context = $this->activity->context; if (!empty($context->replyToID)) { $notice = Notice::staticGet('uri', $context->replyToID); @@ -92,7 +92,7 @@ class UsersalmonAction extends SalmonAction throw new ClientException("Not to anyone in reply to anything!"); } - $existing = Notice::staticGet('uri', $this->act->objects[0]->id); + $existing = Notice::staticGet('uri', $this->activity->objects[0]->id); if (!empty($existing)) { common_log(LOG_ERR, "Not saving notice '{$existing->uri}'; already exists."); @@ -143,7 +143,7 @@ class UsersalmonAction extends SalmonAction function handleFavorite() { - $notice = $this->getNotice($this->act->objects[0]); + $notice = $this->getNotice($this->activity->objects[0]); $profile = $this->ensureProfile()->localProfile(); $old = Fave::pkeyGet(array('user_id' => $profile->id, @@ -164,7 +164,7 @@ class UsersalmonAction extends SalmonAction */ function handleUnfavorite() { - $notice = $this->getNotice($this->act->objects[0]); + $notice = $this->getNotice($this->activity->objects[0]); $profile = $this->ensureProfile()->localProfile(); $fave = Fave::pkeyGet(array('user_id' => $profile->id, From fa778148876cad5d7ecc15866bf880d32d2f9da0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 16 Aug 2010 14:47:18 +1200 Subject: [PATCH 6/8] removed the notice.location column from postgres def -- snuck in on a git commit by Patrick G --- db/statusnet_pg.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/statusnet_pg.sql b/db/statusnet_pg.sql index 2db98550c9..fe0758de89 100644 --- a/db/statusnet_pg.sql +++ b/db/statusnet_pg.sql @@ -136,7 +136,6 @@ create table notice ( is_local integer default 0 /* comment 'notice was generated by a user' */, source varchar(32) /* comment 'source of comment, like "web", "im", or "clientname"' */, conversation integer /*id of root notice in this conversation' */ references notice (id), - location varchar(255) /* comment 'physical location' */, lat decimal(10,7) /* comment 'latitude'*/ , lon decimal(10,7) /* comment 'longitude'*/ , location_id integer /* comment 'location id if possible'*/ , From 7f9ab683b259fc93d507eb705c84af0cfd2fae5b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 16 Aug 2010 13:26:27 +1200 Subject: [PATCH 7/8] fixed a %d that should be a %s in an error message --- lib/installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/installer.php b/lib/installer.php index ff2bed1403..2eff2d85ac 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -319,7 +319,7 @@ abstract class Installer $this->updateStatus(sprintf("Adding %s data to database...", $name)); $res = $this->runDbScript($scr.'.sql', $conn, 'pgsql'); if ($res === false) { - $this->updateStatus(sprintf("Can't run %d script.", $name), true); + $this->updateStatus(sprintf("Can't run %s script.", $name), true); return false; } } From b2a5e0d09b6ef93c265fe4542725de4a7472b103 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 16 Aug 2010 10:09:33 -0700 Subject: [PATCH 8/8] StatusNet 0.9.4 "Orange Crush" --- README | 7 ++----- lib/common.php | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README b/README index 93b63c2acf..e5cb2c933d 100644 --- a/README +++ b/README @@ -2,8 +2,8 @@ README ------ -StatusNet 0.9.4beta2 -11 August 2010 +StatusNet 0.9.4 "Orange Crush" +16 August 2010 This is the README file for StatusNet, the Open Source microblogging platform. It includes installation instructions, descriptions of @@ -88,9 +88,6 @@ For best compatibility with client software and site federation, and a lot of bug fixes, it is highly recommended that all public sites upgrade to the new version. -Changes from 0.9.4beta1: -- fix for daemon config switching on multi-site setup - Notable changes this version: - OpenID and OAuth libraries patched for potential timing attack diff --git a/lib/common.php b/lib/common.php index 897d08b77d..097f19268d 100644 --- a/lib/common.php +++ b/lib/common.php @@ -22,7 +22,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } //exit with 200 response, if this is checking fancy from the installer if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; } -define('STATUSNET_VERSION', '0.9.4beta2'); +define('STATUSNET_VERSION', '0.9.4'); define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility define('STATUSNET_CODENAME', 'Orange Crush');