From ecbba937845cbd4e8e2ed67020b977e1f19fdbd0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 5 May 2017 02:27:24 -0700 Subject: markdown autolinks - hubzilla bug #752 --- Zotlabs/Lib/MarkdownSoap.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index a0214bbe4..534ad819f 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -77,15 +77,22 @@ class MarkdownSoap { } function purify($s) { -// $s = str_replace("\n",'
',$s); -// $s = str_replace("\t",'    ',$s); -// $s = str_replace(' ',' ',$s); + $s = $this->protect_autolinks($s); $s = purify_html($s); -// $s = str_replace([' ', mb_convert_encoding(' ','UTF-8','HTML-ENTITIES')], [ ' ', ' ' ],$s); -// $s = str_replace(['
','
', '<', '>' ],["\n","\n", '<', '>'],$s); + $s = $this->unprotect_autolinks($s); return $s; } + function protect_autolinks($s) { + $s = preg_replace('/\<(https?\:\/\/)(.*?)\>/','[$1$2]($1$2)',$s); + return $s; + } + + function unprotect_autolinks($s) { + return $s; + + } + function escape($s) { return htmlspecialchars($s,ENT_QUOTES); } -- cgit v1.2.3