]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
authorBrion Vibber <brion@pobox.com>
Mon, 22 Mar 2010 19:37:45 +0000 (12:37 -0700)
committerBrion Vibber <brion@pobox.com>
Mon, 22 Mar 2010 19:37:45 +0000 (12:37 -0700)
Conflicts:
lib/attachmentlist.php

index.php
lib/attachmentlist.php
lib/servererroraction.php
plugins/OStatus/actions/userxrd.php
plugins/OStatus/classes/Magicsig.php
plugins/OStatus/classes/Ostatus_profile.php
plugins/OStatus/lib/discovery.php
plugins/OStatus/lib/linkheader.php
plugins/OStatus/lib/safecrypt_rsa.php [new file with mode: 0644]
plugins/OStatus/lib/safemath_biginteger.php [new file with mode: 0644]

index 4c879fe9a9f72d1777acc2ead46e7f34280974ba..6bfbc11da898b57ccd30bf3f5811ca690e4d45c9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -324,10 +324,10 @@ function main()
             $cac = new ClientErrorAction($cex->getMessage(), $cex->getCode());
             $cac->showPage();
         } catch (ServerException $sex) { // snort snort guffaw
-            $sac = new ServerErrorAction($sex->getMessage(), $sex->getCode());
+            $sac = new ServerErrorAction($sex->getMessage(), $sex->getCode(), $sex);
             $sac->showPage();
         } catch (Exception $ex) {
-            $sac = new ServerErrorAction($ex->getMessage());
+            $sac = new ServerErrorAction($ex->getMessage(), 500, $ex);
             $sac->showPage();
         }
     }
index 13dafd13e4818e2102f366efa9e0c73e7adf54d4..d29a5fa2fdb344cd5c56611ba589da53cefb8d74 100644 (file)
@@ -304,7 +304,7 @@ class Attachment extends AttachmentListItem
     function showRepresentation() {
         if (empty($this->oembed->type)) {
             if (empty($this->attachment->mimetype)) {
-                $this->out->element('pre', null, 'oh well... not sure how to handle the following: ' . print_r($this->attachment, true));
+                $this->showFallback();
             } else {
                 switch ($this->attachment->mimetype) {
                 case 'image/gif':
@@ -335,8 +335,12 @@ class Attachment extends AttachmentListItem
                     if ($this->attachment->filename) {
                         // Locally-uploaded HTML. Scrub and display inline.
                         $this->showHtmlFile($this->attachment);
+                        break;
                     }
-                    break;
+                    // Fall through to default
+
+                default:
+                    $this->showFallback();
                 }
             }
         } else {
@@ -359,7 +363,7 @@ class Attachment extends AttachmentListItem
                 break;
 
             default:
-                $this->out->element('pre', null, 'oh well... not sure how to handle the following oembed: ' . print_r($this->oembed, true));
+                $this->showFallback();
             }
         }
     }
@@ -416,5 +420,19 @@ class Attachment extends AttachmentListItem
 
         return $scrubbed;
     }
+
+    function showFallback()
+    {
+        // If we don't know how to display an attachment inline, we probably
+        // shouldn't have gotten to this point.
+        //
+        // But, here we are... displaying details on a file or remote URL
+        // either on the main view or in an ajax-loaded lightbox. As a lesser
+        // of several evils, we'll try redirecting to the actual target via
+        // client-side JS.
+
+        common_log(LOG_ERR, "Empty or unknown type for file id {$this->attachment->id}; falling back to client-side redirect.");
+        $this->out->raw('<script>window.location = ' . json_encode($this->attachment->url) . ';</script>');
+    }
 }
 
index 0993a63bca506149dcecddf892b6d264d4b1cd8e..9b5a553dc64a341e578e2efd6bb08285b017d868 100644 (file)
@@ -62,15 +62,18 @@ class ServerErrorAction extends ErrorAction
                            504 => 'Gateway Timeout',
                            505 => 'HTTP Version Not Supported');
 
-    function __construct($message='Error', $code=500)
+    function __construct($message='Error', $code=500, $ex=null)
     {
         parent::__construct($message, $code);
 
         $this->default = 500;
 
         // Server errors must be logged.
-
-        common_log(LOG_ERR, "ServerErrorAction: $code $message");
+        $log = "ServerErrorAction: $code $message";
+        if ($ex) {
+            $log .= "\n" . $ex->getTraceAsString();
+        }
+        common_log(LOG_ERR, $log);
     }
 
     // XXX: Should these error actions even be invokable via URI?
index eb80a5ad46930d801be6e82735a04fb2a9866010..6a6886eb8c78c06c5126680f68be94df26ac3472 100644 (file)
@@ -35,9 +35,13 @@ class UserxrdAction extends XrdAction
         $this->uri = Discovery::normalize($this->uri);
         
         if (Discovery::isWebfinger($this->uri)) {
-            list($nick, $domain) = explode('@', substr(urldecode($this->uri), 5));
-            $nick = common_canonical_nickname($nick);
-            $this->user = User::staticGet('nickname', $nick);
+            $parts = explode('@', substr(urldecode($this->uri), 5));
+            if (count($parts) == 2) {
+                list($nick, $domain) = $parts;
+                // @fixme confirm the domain too
+                $nick = common_canonical_nickname($nick);
+                $this->user = User::staticGet('nickname', $nick);
+            }
         } else {
             $this->user = User::staticGet('uri', $this->uri);
         }
index 5705ecc1169a3b3abbd1b2a44d70238bc90f7d2a..87c684c93d87702eac562585797a0167070c4ad9 100644 (file)
@@ -27,8 +27,6 @@
  * @link      http://status.net/
  */
 
-require_once 'Crypt/RSA.php';
-
 class Magicsig extends Memcached_DataObject
 {
 
@@ -102,16 +100,16 @@ class Magicsig extends Memcached_DataObject
 
     public function generate($user_id)
     {
-        $rsa = new Crypt_RSA();
+        $rsa = new SafeCrypt_RSA();
         
         $keypair = $rsa->createKey();
 
         $rsa->loadKey($keypair['privatekey']);
 
-        $this->privateKey = new Crypt_RSA();
+        $this->privateKey = new SafeCrypt_RSA();
         $this->privateKey->loadKey($keypair['privatekey']);
 
-        $this->publicKey = new Crypt_RSA();
+        $this->publicKey = new SafeCrypt_RSA();
         $this->publicKey->loadKey($keypair['publickey']);
         
         $this->user_id = $user_id;
@@ -163,7 +161,7 @@ class Magicsig extends Memcached_DataObject
     {
         common_log(LOG_DEBUG, "Adding ".$type." key: (".$mod .', '. $exp .")");
 
-        $rsa = new Crypt_RSA();
+        $rsa = new SafeCrypt_RSA();
         $rsa->signatureMode = CRYPT_RSA_SIGNATURE_PKCS1;
         $rsa->setHash('sha256');
         $rsa->modulus = new Math_BigInteger(base64_url_decode($mod), 256);
index de5175427c7b4ca061237bf14641a8e24dbf347e..15e149125ac63119eeba1d82302632812c60f2bb 100644 (file)
@@ -442,6 +442,17 @@ class Ostatus_profile extends Memcached_DataObject
     {
         $activity = new Activity($entry, $feed);
 
+        switch ($activity->object->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 ($activity->verb == ActivityVerb::POST) {
             $this->processPost($activity, $source);
         } else {
index 44fad62fbdc51d8d99c0239f19db321fad149444..7187c1f3e95ca122f704d52b4d92f6712e23dead 100644 (file)
@@ -195,7 +195,7 @@ class Discovery_LRDD_Link_Header implements Discovery_LRDD
             //            return false;
         }
 
-        return Discovery_LRDD_Link_Header::parseHeader($link_header);
+        return array(Discovery_LRDD_Link_Header::parseHeader($link_header));
     }
 
     protected static function parseHeader($header)
index afcd66d264d6be67b9337eeb6abddfd1d5cb6ea4..cd78d31cef6ce325c4e1959f1dae391c562e0855 100644 (file)
@@ -11,7 +11,7 @@ class LinkHeader
         preg_match('/^<[^>]+>/', $str, $uri_reference);
         //if (empty($uri_reference)) return;
 
-        $this->uri = trim($uri_reference[0], '<>');
+        $this->href = trim($uri_reference[0], '<>');
         $this->rel = array();
         $this->type = null;
 
diff --git a/plugins/OStatus/lib/safecrypt_rsa.php b/plugins/OStatus/lib/safecrypt_rsa.php
new file mode 100644 (file)
index 0000000..f3aa2c9
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+require_once 'Crypt/RSA.php';
+
+/**
+ * Crypt_RSA stores a Math_BigInteger with value 0, which triggers a bug
+ * in Math_BigInteger's wakeup function which spews notices to log or output.
+ * This wrapper replaces it with a version that survives serialization.
+ */
+class SafeCrypt_RSA extends Crypt_RSA
+{
+    function __construct()
+    {
+        parent::__construct();
+        $this->zero = new SafeMath_BigInteger();
+    }
+}
+
diff --git a/plugins/OStatus/lib/safemath_biginteger.php b/plugins/OStatus/lib/safemath_biginteger.php
new file mode 100644 (file)
index 0000000..c05e24d
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+require_once 'Math/BigInteger.php';
+
+/**
+ * Crypt_RSA stores a Math_BigInteger with value 0, which triggers a bug
+ * in Math_BigInteger's wakeup function which spews notices to log or output.
+ * This wrapper replaces it with a version that survives serialization.
+ */
+class SafeMath_BigInteger extends Math_BigInteger
+{
+    function __wakeup()
+    {
+        if ($this->hex == '') {
+            $this->hex = '0';
+        }
+        parent::__wakeup();
+    }
+}
+