]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activityimporter.php
Merge branch 'nightly' into 'nightly'
[quix0rs-gnu-social.git] / lib / activityimporter.php
index 27f89225c2ba93ac49d30f1bace8d6ad61572a5c..c4dd797e6d8076e11767e1fcb9a950b05aca30fa 100644 (file)
@@ -109,20 +109,21 @@ class ActivityImporter extends QueueHandler
 
             // XXX: don't do this for untrusted input!
 
-            Subscription::start($otherProfile, $profile);
+            Subscription::ensureStart($otherProfile, $profile);
         } else if (empty($activity->actor)
                    || $activity->actor->id == $author->id) {
 
             $other = $activity->objects[0];
 
-            $otherProfile = Profile::fromUri($other->id);
-
-            if (empty($otherProfile)) {
+            try {
+                $otherProfile = Profile::fromUri($other->id);
                 // TRANS: Client exception thrown when trying to subscribe to an unknown profile.
+            } catch (UnknownUriException $e) {
+                // Let's convert it to a client exception instead of server.
                 throw new ClientException(_('Unknown profile.'));
             }
 
-            Subscription::start($profile, $otherProfile);
+            Subscription::ensureStart($profile, $otherProfile);
         } else {
             // TRANS: Client exception thrown when trying to import an event not related to the importing user.
             throw new Exception(_('This activity seems unrelated to our user.'));
@@ -212,8 +213,8 @@ class ActivityImporter extends QueueHandler
 
         // Get (safe!) HTML and text versions of the content
 
-        $rendered = $this->purify($sourceContent);
-        $content = html_entity_decode(strip_tags($rendered), ENT_QUOTES, 'UTF-8');
+        $rendered = common_purify($sourceContent);
+        $content = common_strip_html($rendered);
 
         $shortened = $user->shortenLinks($content);
 
@@ -337,15 +338,4 @@ class ActivityImporter extends QueueHandler
 
         return array($groups, $replies);
     }
-
-
-    function purify($content)
-    {
-        require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
-
-        $config = array('safe' => 1,
-                        'deny_attribute' => 'id,style,on*');
-
-        return htmLawed($content, $config);
-    }
 }