]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
Don't trust local HTML either
[quix0rs-gnu-social.git] / lib / util.php
index fd903d5505a2db28a60f5f277489742516236b93..7ebbf42cf601f58feed5b75ed3af1e3f3486ece1 100644 (file)
@@ -681,6 +681,23 @@ function common_linkify_mention(array $mention)
     return $output;
 }
 
+function common_get_attentions($text, Profile $sender, Notice $parent=null)
+{
+    $mentions = common_find_mentions($text, $sender, $parent);
+    $atts = array();
+    foreach ($mentions as $mention) {
+        foreach ($mention['mentioned'] as $mentioned) {
+            $atts[$mentioned->getUri()] = $mentioned->getObjectType();
+        }
+    }
+    if ($parent instanceof Notice) {
+        $parentAuthor = $parent->getProfile();
+        // afaik groups can't be authors
+        $atts[$parentAuthor->getUri()] = ActivityObject::PERSON;
+    }
+    return $atts;
+}
+
 /**
  * Find @-mentions in the given text, using the given notice object as context.
  * References will be resolved with common_relative_profile() against the user
@@ -997,9 +1014,9 @@ function common_linkify($url) {
 
     // Check to see whether this is a known "attachment" URL.
 
-    $f = File::getKV('url', $longurl);
-
-    if (!$f instanceof File) {
+    try {
+        $f = File::getByUrl($longurl);
+    } catch (NoResultException $e) {
         if (common_config('attachments', 'process_links')) {
             // XXX: this writes to the database. :<
             try {
@@ -2436,4 +2453,4 @@ function html_sprintf()
         $args[$i] = htmlspecialchars($args[$i]);
     }
     return call_user_func_array('sprintf', $args);
-}
\ No newline at end of file
+}