]> 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 3b5bb2de08aa2dde81822e7fd27d2b49b52ab7a3..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
@@ -980,10 +997,16 @@ function common_linkify($url) {
     } else {
         $canon = File_redirection::_canonUrl($url);
         $longurl_data = File_redirection::where($canon, common_config('attachments', 'process_links'));
-        $longurl = $longurl_data->url;
+        
+        if(isset($longurl_data->redir_url)) {
+                       $longurl = $longurl_data->redir_url;
+        } else {
+            // e.g. local files
+               $longurl = $longurl_data->url;
+        }
     }
-
-    $attrs = array('href' => $canon, 'title' => $longurl);
+    
+    $attrs = array('href' => $longurl, 'title' => $longurl);
 
     $is_attachment = false;
     $attachment_id = null;
@@ -991,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 {