From 3b73e5223e4a0f9dfae3a456ff5b3b6dec03ab76 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 15 Jul 2019 15:05:54 +0200 Subject: stringify_array_elms() could return weird results if the initial array key was not zero. this could trigger obscure bugs e.g. adding an empty string value to the recipients array in the notifier which could then select some broken hubloc/xchan entries. --- include/text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index a2dfda952..8ce6b5d7c 100644 --- a/include/text.php +++ b/include/text.php @@ -2456,8 +2456,8 @@ function magic_link($s) { * @param boolean $escape (optional) default false */ function stringify_array_elms(&$arr, $escape = false) { - for($x = 0; $x < count($arr); $x ++) - $arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'"; + foreach($arr as $k => $v) + $arr[$k] = "'" . (($escape) ? dbesc($v) : $v) . "'"; } -- cgit v1.2.3 From 821af482f070bfc671d2f5b6480a370dc86f212e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 16 Jul 2019 18:11:47 +0200 Subject: Exclude trailing punctuations from URL --- include/text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 8ce6b5d7c..17fd1bfe4 100644 --- a/include/text.php +++ b/include/text.php @@ -3403,10 +3403,10 @@ function cleanup_bbcode($body) { $body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','\red_escape_codeblock',$body); $body = preg_replace_callback("/([^\]\='".'"'."\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)/ismu", '\nakedoembed', $body); ++\,\(\)]+)([\,\.\:\;]\s|$)/ismu", '\nakedoembed', $body); $body = preg_replace_callback("/([^\]\='".'"'."\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)/ismu", '\red_zrl_callback', $body); ++\,\(\)]+)([\,\.\:\;]\s|$)/ismu", '\red_zrl_callback', $body); $body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','\red_unescape_codeblock',$body); -- cgit v1.2.3 From c4de5b45dfead76bc564d306ac2c3f0c407dbe6f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 18 Jul 2019 13:19:10 +0200 Subject: do not format hashtags with missing url --- include/text.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 17fd1bfe4..5a0e6ad3d 100644 --- a/include/text.php +++ b/include/text.php @@ -1572,7 +1572,9 @@ function format_hashtags(&$item) { $term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ; if(! trim($term)) continue; - if($t['url'] && strpos($item['body'], $t['url'])) + if(empty($t['url'])) + continue; + if(strpos($item['body'], $t['url'])) continue; if($s) $s .= ' '; -- cgit v1.2.3 From dc56d8560d0786a50f5131d114e0fb17b5b85d9c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 22 Jul 2019 20:38:10 +0200 Subject: pleroma uses slightly different URLs in body - also look for the string --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 5a0e6ad3d..1cde6bb01 100644 --- a/include/text.php +++ b/include/text.php @@ -1574,7 +1574,7 @@ function format_hashtags(&$item) { continue; if(empty($t['url'])) continue; - if(strpos($item['body'], $t['url'])) + if(strpos($item['body'], $t['url']) || strpos($item['body'], '#' . $t['term'])) continue; if($s) $s .= ' '; -- cgit v1.2.3 From 5695350e98a8a2c802ff419c5b29b0f01f0180df Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 25 Jul 2019 12:25:27 +0200 Subject: Revert "Merge branch 'dev' into 'dev'" This reverts merge request !1694 --- include/text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 1cde6bb01..8adcc1269 100644 --- a/include/text.php +++ b/include/text.php @@ -3405,10 +3405,10 @@ function cleanup_bbcode($body) { $body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','\red_escape_codeblock',$body); $body = preg_replace_callback("/([^\]\='".'"'."\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)([\,\.\:\;]\s|$)/ismu", '\nakedoembed', $body); ++\,\(\)]+)/ismu", '\nakedoembed', $body); $body = preg_replace_callback("/([^\]\='".'"'."\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)([\,\.\:\;]\s|$)/ismu", '\red_zrl_callback', $body); ++\,\(\)]+)/ismu", '\red_zrl_callback', $body); $body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','\red_unescape_codeblock',$body); -- cgit v1.2.3