]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix for ticket 2513: "Can't linkify" error when some links are shortened
authorBrion Vibber <brion@status.net>
Thu, 12 Aug 2010 22:19:47 +0000 (15:19 -0700)
committerBrion Vibber <brion@status.net>
Thu, 12 Aug 2010 22:25:32 +0000 (15:25 -0700)
When bogus SSL sites etc were hit through a shortening redirect, sometimes link resolution kinda blew up and the user would get a "Can't linkify" error, aborting their post.
Now catching this case and just passing through the URL without attempting to resolve it. Could benefit from an overall scrubbing of the freaky link/attachment code though...! :)

http://status.net/open-source/issues/2513

classes/File_redirection.php
lib/util.php

index f128b3e07c84179e92369de9b732800da1000d16..51b8be3b06e6606bf51ce1effcaf9e81234e2ee2 100644 (file)
@@ -210,6 +210,14 @@ class File_redirection extends Memcached_DataObject
                 } else if (is_string($redir_data)) {
                     // The file is a known redirect target.
                     $file = File::staticGet('url', $redir_data);
+                    if (empty($file)) {
+                        // @fixme should we save a new one?
+                        // this case was triggering sometimes for redirects
+                        // with unresolvable targets; found while fixing
+                        // "can't linkify" bugs with shortened links to
+                        // SSL sites with cert issues.
+                        return null;
+                    }
                     $file_id = $file->id;
                 }
             } else {
index 9f62097d544a28acf4a53f50633bc2a7a867b212..66600c766f023768634f4c3939c521d0ddde95ce 100644 (file)
@@ -830,7 +830,10 @@ function common_linkify($url) {
         } elseif (is_string($longurl_data)) {
             $longurl = $longurl_data;
         } else {
-            throw new ServerException("Can't linkify url '$url'");
+            // Unable to reach the server to verify contents, etc
+            // Just pass the link on through for now.
+            common_log(LOG_ERR, "Can't linkify url '$url'");
+            $longurl = $url;
         }
     }
     $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external');