From 64f2f3d976e344d3bfa2dbddb937c90a0c4fe55c Mon Sep 17 00:00:00 2001 From: hannes Date: Tue, 5 Jan 2016 22:44:06 +0000 Subject: [PATCH 1/4] effectiveUrl seems to contain the url we want --- lib/httpclient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/httpclient.php b/lib/httpclient.php index 4b854914c9..b386ce3987 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -80,7 +80,7 @@ class GNUsocial_HTTPResponse extends HTTP_Request2_Response */ function getUrl() { - return $this->url; + return $this->effectiveUrl; } /** @@ -360,4 +360,4 @@ class HTTPClient extends HTTP_Request2 } while ($maxRedirs); return new GNUsocial_HTTPResponse($response, $this->getUrl(), $redirs); } -} +} \ No newline at end of file From 8b78e01d4c4b9512a7b74efa52fcaf37de0dc6f1 Mon Sep 17 00:00:00 2001 From: hannes Date: Tue, 5 Jan 2016 23:06:02 +0000 Subject: [PATCH 2/4] $longurl->url is just the same $canon we fed to File_redirection::where() --- lib/util.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.php b/lib/util.php index 3b5bb2de08..c03775f577 100644 --- a/lib/util.php +++ b/lib/util.php @@ -980,7 +980,7 @@ 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; + $longurl = $longurl_data->redir_url; } $attrs = array('href' => $canon, 'title' => $longurl); @@ -2430,4 +2430,4 @@ function html_sprintf() $args[$i] = htmlspecialchars($args[$i]); } return call_user_func_array('sprintf', $args); -} +} \ No newline at end of file From 1c25cffbd845d42d8e081282fddb9a491cecb71b Mon Sep 17 00:00:00 2001 From: hannes Date: Tue, 5 Jan 2016 23:07:24 +0000 Subject: [PATCH 3/4] add $redir->redir_url to use in common_linkify() --- classes/File_redirection.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/File_redirection.php b/classes/File_redirection.php index a324deaa5d..03df3de1b1 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -195,6 +195,7 @@ class File_redirection extends Managed_DataObject $redir->httpcode = $redir_info['code']; $redir->redirections = intval($redir_info['redirects']); + $redir->redir_url = $redir_info['url']; $redir->file = new File(); $redir->file->url = $redir_info['url']; $redir->file->mimetype = $redir_info['type']; @@ -396,4 +397,4 @@ class File_redirection extends Managed_DataObject return $this->file; } -} +} \ No newline at end of file From 0b4b0de412393001f1854e4be40ebf136959c9f6 Mon Sep 17 00:00:00 2001 From: hannes Date: Tue, 5 Jan 2016 23:14:51 +0000 Subject: [PATCH 4/4] longurl in href --- lib/util.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/util.php b/lib/util.php index c03775f577..fd903d5505 100644 --- a/lib/util.php +++ b/lib/util.php @@ -980,10 +980,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->redir_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;