From f7d599f8eac0a9e3d47c3ff2f074bed0b6e9c124 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 12 Aug 2010 15:19:47 -0700 Subject: [PATCH 1/5] Fix for ticket 2513: "Can't linkify" error when some links are shortened When bogus SSL sites etc were hit through a shortening redirect, sometimes link resolution kinda blew up and the user would get a "Can't linkify" error, aborting their post. Now catching this case and just passing through the URL without attempting to resolve it. Could benefit from an overall scrubbing of the freaky link/attachment code though...! :) http://status.net/open-source/issues/2513 --- classes/File_redirection.php | 8 ++++++++ lib/util.php | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/classes/File_redirection.php b/classes/File_redirection.php index f128b3e07c..51b8be3b06 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -210,6 +210,14 @@ class File_redirection extends Memcached_DataObject } else if (is_string($redir_data)) { // The file is a known redirect target. $file = File::staticGet('url', $redir_data); + if (empty($file)) { + // @fixme should we save a new one? + // this case was triggering sometimes for redirects + // with unresolvable targets; found while fixing + // "can't linkify" bugs with shortened links to + // SSL sites with cert issues. + return null; + } $file_id = $file->id; } } else { diff --git a/lib/util.php b/lib/util.php index 9f62097d54..66600c766f 100644 --- a/lib/util.php +++ b/lib/util.php @@ -830,7 +830,10 @@ function common_linkify($url) { } elseif (is_string($longurl_data)) { $longurl = $longurl_data; } else { - throw new ServerException("Can't linkify url '$url'"); + // Unable to reach the server to verify contents, etc + // Just pass the link on through for now. + common_log(LOG_ERR, "Can't linkify url '$url'"); + $longurl = $url; } } $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external'); From d06bdfa54bab19c04d4e4dd74801df57bcd5a19c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 12 Aug 2010 18:42:09 -0700 Subject: [PATCH 2/5] add note about software subscription --- README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README b/README index c202443545..93b63c2acf 100644 --- a/README +++ b/README @@ -43,6 +43,10 @@ on status.net is identical to the software available for download, so you can move back and forth between a hosted version or a version installed on your own servers. +A commercial software subscription is available from StatusNet Inc. It +includes 24-hour technical support and developer support. More +information at http://status.net/contact or email sales@status.net. + License ======= From 4217277d14ef1b244a15a8c2fe5dd41e7be6ed1e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 13 Aug 2010 13:07:25 -0700 Subject: [PATCH 3/5] 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 8dec16aeebc723d36e31f4a3fa5e695bdf92647b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 13 Aug 2010 13:14:47 -0700 Subject: [PATCH 4/5] add hooks to allow plugins to handle different kinds of activities --- plugins/OStatus/classes/Ostatus_profile.php | 35 ++++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 8f8eb773f8..1fae468f66 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -445,26 +445,31 @@ class Ostatus_profile extends Memcached_DataObject * @param DOMElement $feed for context * @param string $source identifier ("push" or "salmon") */ + public function processEntry($entry, $feed, $source) { $activity = new Activity($entry, $feed); - // @todo process all activity objects - switch ($activity->objects[0]->type) { - case ActivityObject::ARTICLE: - case ActivityObject::BLOGENTRY: - case ActivityObject::NOTE: - case ActivityObject::STATUS: - case ActivityObject::COMMENT: - break; - default: - throw new ClientException("Can't handle that kind of post."); - } + if (Event::handle('StartHandleFeedEntry', array($activity))) { - if ($activity->verb == ActivityVerb::POST) { - $this->processPost($activity, $source); - } else { - common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb"); + // @todo process all activity objects + switch ($activity->objects[0]->type) { + case ActivityObject::ARTICLE: + case ActivityObject::BLOGENTRY: + case ActivityObject::NOTE: + case ActivityObject::STATUS: + case ActivityObject::COMMENT: + if ($activity->verb == ActivityVerb::POST) { + $this->processPost($activity, $source); + } else { + common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb"); + } + break; + default: + throw new ClientException("Can't handle that kind of post."); + } + + Event::handle('EndHandleFeedEntry', array($activity)); } } From 029aa0c61c9942c0688fd3dc9aa2893311543db1 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 13 Aug 2010 14:18:54 -0700 Subject: [PATCH 5/5] 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,