aboutsummaryrefslogtreecommitdiffstats
path: root/include/markdown.php
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2020-01-12 18:24:59 +0100
committerMax Kostikov <max@kostikov.co>2020-01-12 18:24:59 +0100
commita1ccacb825edac6ae36e5db4f62ebfe7aeaebe9f (patch)
treec6e135b3e0acab8f7ad91551e6b5ecb7260d205a /include/markdown.php
parent908875a052ac76e24af74fc714b350c217de42b4 (diff)
downloadvolse-hubzilla-a1ccacb825edac6ae36e5db4f62ebfe7aeaebe9f.tar.gz
volse-hubzilla-a1ccacb825edac6ae36e5db4f62ebfe7aeaebe9f.tar.bz2
volse-hubzilla-a1ccacb825edac6ae36e5db4f62ebfe7aeaebe9f.zip
Fix wrong URL detection with Markdown support enabled
Diffstat (limited to 'include/markdown.php')
-rw-r--r--include/markdown.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/markdown.php b/include/markdown.php
index 69cc264df..0bfe595b8 100644
--- a/include/markdown.php
+++ b/include/markdown.php
@@ -76,7 +76,7 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) {
$s = html2bbcode($s);
- $s = bb_code_protect($s);
+ // $s = bb_code_protect($s);
// Convert everything that looks like a link to a link
if($use_zrl) {
@@ -84,13 +84,13 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) {
$s = preg_replace_callback("/\[img\](.*?)\[\/img\]/ism", 'use_zrl_cb_img', $s);
$s = preg_replace_callback("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", 'use_zrl_cb_img_x', $s);
}
- $s = preg_replace_callback("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", 'use_zrl_cb_link',$s);
+ $s = preg_replace_callback("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)([\,\.\:\;]\s|$)/ismu", 'use_zrl_cb_link',$s);
}
else {
- $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", '$1[url=$2$3]$2$3[/url]',$s);
+ $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)([\,\.\:\;]\s|$)/ismu", '$1[url=$2$3]$2$3[/url]$4',$s);
}
- $s = bb_code_unprotect($s);
+ // $s = bb_code_unprotect($s);
// remove duplicate adjacent code tags
$s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s);
@@ -110,9 +110,9 @@ function use_zrl_cb_link($match) {
$is_zid = is_matrix_url(trim($match[0]));
if($is_zid)
- $res = $match[1] . '[zrl=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/zrl]';
+ $res = $match[1] . '[zrl=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/zrl]' . $match[4];
else
- $res = $match[1] . '[url=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/url]';
+ $res = $match[1] . '[url=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/url]' . $match[4];
return $res;
}