aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2019-08-08 18:53:14 +0200
committerMax Kostikov <max@kostikov.co>2019-08-08 18:53:14 +0200
commit699aad8626e586b8d14a5fb18df30ccae4ff425e (patch)
treea0862b1213f7fb4bc4396fbe4ef42b4927f72680 /include
parent03c4fba730bf13c2cda03d7ec655bdc5463762d2 (diff)
parent4382e53acbd9e5fa071428a6f365a637561f6820 (diff)
downloadvolse-hubzilla-699aad8626e586b8d14a5fb18df30ccae4ff425e.tar.gz
volse-hubzilla-699aad8626e586b8d14a5fb18df30ccae4ff425e.tar.bz2
volse-hubzilla-699aad8626e586b8d14a5fb18df30ccae4ff425e.zip
Merge branch 'dev' into 'dev'
Catch and exclude trailing punctuation while URL embedding See merge request hubzilla/core!1701
Diffstat (limited to 'include')
-rw-r--r--include/zid.php33
1 files changed, 19 insertions, 14 deletions
diff --git a/include/zid.php b/include/zid.php
index 27ef0cefa..3b3dd8554 100644
--- a/include/zid.php
+++ b/include/zid.php
@@ -205,20 +205,25 @@ function zidify_text($s) {
*/
function red_zrl_callback($matches) {
- $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]';
-
- return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]';
+ // Catch and exclude trailing punctuation
+ 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] = '';
+
+ if($zrl)
+ return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0];
+
+ return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0];
}
/**