From b82e80ce9431deed3643f810d39feaca1e86dc28 Mon Sep 17 00:00:00 2001 From: Kelson Vibber Date: Mon, 13 Jun 2022 00:42:51 -0700 Subject: [PATCH] Fix bugs with plaintext URLs at the end of a block. --- readme.md | 7 ++++--- readme.txt | 5 ++++- unwrap-shortlinks.php | 5 ++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index cfbfbcf..ebf1ca7 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Unwrap Shortlinks -Stable tag: 0.2.3 +Stable tag: 0.2.4 Tags: urls, links, classicpress Requires at least: 3.0 Tested up to: 6.0 @@ -60,12 +60,13 @@ Thanks to [igienger's post](https://wordpress.org/support/topic/error-curl-error ### What about compatibility? -TODO: It's stopped working with the block editor. I'll fix this asap. - It should work going back to the classic editor and forward to the block editor. It even works on [ClassicPress](https://www.classicpress.net/). ## Changelog +### [0.2.4] - 2022-06-13 +* Fix bugs with plaintext URLs at the end of a block. + ### [0.2.3] - 2022-06-10 * Fix bugs with tinyurl.com and URLs inside HTML links. (Plaintext URLs were working fine.) diff --git a/readme.txt b/readme.txt index 8dcf361..2256209 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ === Unwrap Shortlinks === -Stable tag: 0.2.3 +Stable tag: 0.2.4 Tags: urls, links, classicpress Requires at least: 3.0 Tested up to: 6.0 @@ -60,6 +60,9 @@ Thanks to [igienger's post](https://wordpress.org/support/topic/error-curl-error == Changelog == += [0.2.4] - 2022-06-13 = +* Fix bugs with plaintext URLs at the end of a block. + = [0.2.3] - 2022-06-10 = * Fix bugs with tinyurl.com and URLs inside HTML links. (Plaintext URLs were working fine.) diff --git a/unwrap-shortlinks.php b/unwrap-shortlinks.php index 917594c..4fcc7f1 100644 --- a/unwrap-shortlinks.php +++ b/unwrap-shortlinks.php @@ -3,7 +3,7 @@ Plugin Name: Unwrap Shortlinks Plugin URI: https://codeberg.org/kvibber/unwrap-shortlinks Description: Follow shortened links (t.co, bit.ly, etc) and expand them so that your blog post will point directly to the destination. - Version: 0.2.3 + Version: 0.2.4 Author: Kelson Vibber Author URI: https://kvibber.com License: GPLv2 or later @@ -13,7 +13,7 @@ // ini_set('display_errors', '1'); ini_set('error_reporting', E_ALL); function ktv_unwrap_shortlinks($content) { - preg_match_all('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|tinyurl\.com|goo\.gl|dlvr\.it|fb\.me|qr\.ae)\/[^\s"\']+)\b/', $content, $matches, PREG_PATTERN_ORDER); + preg_match_all('/\b(https?:\/\/(?:t\.co|bit\.ly|j\.mp|ow\.ly|is\.gd|trib\.al|buff\.ly|tmblr\.co|wp\.me|tinyurl\.com|goo\.gl|dlvr\.it|fb\.me|qr\.ae)\/[^\s"\'<>]+)\b/', $content, $matches, PREG_PATTERN_ORDER); foreach ($matches[1] as $link) { $getlink = ktv_unwrap_shortlinks_replace($link); if ($getlink != "") @@ -40,5 +40,4 @@ function ktv_unwrap_shortlinks_replace($url) { add_filter('content_save_pre', 'ktv_unwrap_shortlinks', 700); - ?>