From 2300581c93d0f40b1972774e05f493332729a948 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:19:07 +0200 Subject: Catch and exclude trailing punctuation while URL embedding --- include/zid.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/zid.php b/include/zid.php index 27ef0cefa..344976437 100644 --- a/include/zid.php +++ b/include/zid.php @@ -205,6 +205,10 @@ function zidify_text($s) { */ function red_zrl_callback($matches) { + // Catch and exclude trailing punctuation + if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts)) + $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); + $zrl = is_matrix_url($matches[2]); $t = strip_zids($matches[2]); @@ -215,10 +219,11 @@ function red_zrl_callback($matches) { if($matches[1] === '#^') $matches[1] = ''; + if($zrl) - return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]'; + return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; - return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]'; + return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0]; } /** -- cgit v1.2.3 From 1c2f4132113a38948468fa992b738cb864e67774 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:27:07 +0200 Subject: Formatting --- include/zid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zid.php b/include/zid.php index 344976437..05161d5c2 100644 --- a/include/zid.php +++ b/include/zid.php @@ -205,7 +205,7 @@ function zidify_text($s) { */ function red_zrl_callback($matches) { - // Catch and exclude trailing punctuation + // Catch and exclude trailing punctuation if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts)) $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); -- cgit v1.2.3 From 33e258291870fcfe22ea8522c5e97d3bdeb84437 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:29:26 +0200 Subject: Update zid.php --- include/zid.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/zid.php b/include/zid.php index 05161d5c2..4b17e1cd2 100644 --- a/include/zid.php +++ b/include/zid.php @@ -208,20 +208,20 @@ function red_zrl_callback($matches) { // Catch and exclude trailing punctuation if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts)) $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); - - $zrl = is_matrix_url($matches[2]); - - $t = strip_zids($matches[2]); - if($t !== $matches[2]) { - $zrl = true; - $matches[2] = $t; - } - - if($matches[1] === '#^') - $matches[1] = ''; - + + $zrl = is_matrix_url($matches[2]); + + $t = strip_zids($matches[2]); + if($t !== $matches[2]) { + $zrl = true; + $matches[2] = $t; + } + + if($matches[1] === '#^') + $matches[1] = ''; + if($zrl) - return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; + return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0]; } -- cgit v1.2.3 From 832adf92a65489dd9ee253453d1421e36a9af9d5 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:30:08 +0200 Subject: Update zid.php --- include/zid.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/zid.php b/include/zid.php index 4b17e1cd2..aaa509a09 100644 --- a/include/zid.php +++ b/include/zid.php @@ -219,11 +219,11 @@ function red_zrl_callback($matches) { if($matches[1] === '#^') $matches[1] = ''; - - if($zrl) - return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; - - return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0]; + + if($zrl) + return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0]; + + return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0]; } /** -- cgit v1.2.3 From 4382e53acbd9e5fa071428a6f365a637561f6820 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 8 Aug 2019 18:37:05 +0200 Subject: Remove condition --- include/zid.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/zid.php b/include/zid.php index aaa509a09..3b3dd8554 100644 --- a/include/zid.php +++ b/include/zid.php @@ -206,8 +206,8 @@ function zidify_text($s) { function red_zrl_callback($matches) { // Catch and exclude trailing punctuation - if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts)) - $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); + preg_match("/[.,;:!?)]*$/i", $matches[2], $pts); + $matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0])); $zrl = is_matrix_url($matches[2]); -- cgit v1.2.3