]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Pull <atom:author> info as well as <activity:actor> when we have an old-style Activit...
authorBrion Vibber <brion@pobox.com>
Sun, 21 Mar 2010 23:25:12 +0000 (16:25 -0700)
committerBrion Vibber <brion@pobox.com>
Sun, 21 Mar 2010 23:25:12 +0000 (16:25 -0700)
lib/activityobject.php
lib/activityutils.php
plugins/OStatus/classes/Ostatus_profile.php

index e5cea727b77b343bcaf394e304f91d66a90a9da3..0a358ccabbe1c4ceb34199b7f0badc80485a64b3 100644 (file)
@@ -156,7 +156,11 @@ class ActivityObject
     {
         $this->type  = self::PERSON; // XXX: is this fair?
         $this->title = $this->_childContent($element, self::NAME);
-        $this->id    = $this->_childContent($element, self::URI);
+
+        $id = $this->_childContent($element, self::URI);
+        if (ActivityUtils::validateUri($id)) {
+            $this->id = $id;
+        }
 
         if (empty($this->id)) {
             $email = $this->_childContent($element, self::EMAIL);
@@ -169,6 +173,15 @@ class ActivityObject
 
     private function _fromAtomEntry($element)
     {
+        if ($element->localName == 'actor') {
+            // Old-fashioned <activity:actor>...
+            // First pull anything from <author>, then we'll add on top.
+            $author = ActivityUtils::child($element->parentNode, 'author');
+            if ($author) {
+                $this->_fromAuthor($author);
+            }
+        }
+
         $this->type = $this->_childContent($element, Activity::OBJECTTYPE,
                                            Activity::SPEC);
 
@@ -176,7 +189,11 @@ class ActivityObject
             $this->type = ActivityObject::NOTE;
         }
 
-        $this->id      = $this->_childContent($element, self::ID);
+        $id = $this->_childContent($element, self::ID);
+        if (ActivityUtils::validateUri($id)) {
+            $this->id = $id;
+        }
+
         $this->summary = ActivityUtils::childHtmlContent($element, self::SUMMARY);
         $this->content = ActivityUtils::getContent($element);
 
index c85a3db5560f0ba8ac7c8490da532bd7c8533416..a7e99fb11e32b91762649247fb51a2b80c9d3b42 100644 (file)
@@ -240,4 +240,26 @@ class ActivityUtils
             throw new ClientException(_("Can't handle embedded Base64 content yet."));
         }
     }
+
+    /**
+     * Is this a valid URI for remote profile/notice identification?
+     * Does not have to be a resolvable URL.
+     * @param string $uri
+     * @return boolean
+     */
+    static function validateUri($uri)
+    {
+        if (Validate::uri($uri)) {
+            return true;
+        }
+
+        // Possibly an upstream bug; tag: URIs aren't validated properly
+        // unless you explicitly ask for them. All other schemes are accepted
+        // for basic URI validation without asking.
+        if (Validate::uri($uri, array('allowed_scheme' => array('tag')))) {
+            return true;
+        }
+
+        return false;
+    }
 }
index 5595a9d29825cc7350f87f348bedea38d6bc8256..e33509c47146a284aca9d55cb310e58f1846e962 100644 (file)
@@ -1170,11 +1170,7 @@ class Ostatus_profile extends Memcached_DataObject
     protected static function getActivityObjectProfileURI($object)
     {
         if ($object->id) {
-            // Possibly an upstream bug; tag: URIs are rejected unless you
-            // explicitly ask for them. All other schemes are accepted for
-            // basic URI validation without asking.
-            if (Validate::uri($object->id) ||
-                Validate::uri($object->id, array('allowed_scheme' => array('tag')))) {
+            if (ActivityUtils::validateUri($object->id)) {
                 return $object->id;
             }
         }