From 77e1ec6df2076183cf3643170a474278f368f968 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 May 2021 17:33:32 +0000 Subject: [PATCH 1/2] Improved link detection --- src/Content/PageInfo.php | 9 +++++++-- src/Model/Item.php | 10 +++++++++- src/Model/Post/Media.php | 24 ++++++++++++++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/Content/PageInfo.php b/src/Content/PageInfo.php index 7226ff2a44..21f32cd3c3 100644 --- a/src/Content/PageInfo.php +++ b/src/Content/PageInfo.php @@ -253,10 +253,15 @@ class PageInfo // Fix for Mastodon where the mentions are in a different format $body = preg_replace("~\[url=($URLSearchString)]([#!@])(.*?)\[/url]~is", '$2[url=$1]$3[/url]', $body); - preg_match("~(? Date: Sun, 2 May 2021 17:53:11 +0000 Subject: [PATCH 2/2] Only detect http links --- src/Content/PageInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Content/PageInfo.php b/src/Content/PageInfo.php index 21f32cd3c3..d3b38336b5 100644 --- a/src/Content/PageInfo.php +++ b/src/Content/PageInfo.php @@ -257,11 +257,11 @@ class PageInfo $body = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '', $body); // Search for pure links - preg_match("/\[url\](.*?)\[\/url\]/ism", $body, $matches); + preg_match("/\[url\](https?:.*?)\[\/url\]/ism", $body, $matches); if (!$matches) { // Search for links with descriptions - preg_match("/\[url\=(.*?)\].*?\[\/url\]/ism", $body, $matches); + preg_match("/\[url\=(https?:.*?)\].*?\[\/url\]/ism", $body, $matches); } if (!$matches && $searchNakedUrls) {