From d4240a265b6993e8afe0a6f528db3b0d70b6e3e3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 15 May 2013 22:20:06 +0200 Subject: [PATCH 1/2] When converting to HTML, hashtag addresses are now removed (only when the message is exported) --- include/bbcode.php | 6 ++++++ include/html2plain.php | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/include/bbcode.php b/include/bbcode.php index 01c8f14df9..d16dcb6a7f 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -668,6 +668,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal // $Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES'); //} + // Remove all hashtag addresses + if (!$tryoembed) { + $pattern = '/#(.*?)<\/a>/is'; + $Text = preg_replace($pattern, '#$2', $Text); + } + call_hooks('bbcode',$Text); $a->save_timestamp($stamp1, "parser"); diff --git a/include/html2plain.php b/include/html2plain.php index 1e3f407af4..80768ffff7 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -107,6 +107,10 @@ function html2plain($html, $wraplength = 75, $compact = false) $message = str_replace("\r", "", $html); + // replace all hashtag addresses + $pattern = '/#(.*?)<\/a>/is'; + $message = preg_replace($pattern, '#$2', $message); + $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; From 0723933c1c79eb3eacb4b3433fdb109208972308 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 19 May 2013 11:08:08 +0200 Subject: [PATCH 2/2] removing of hashtag addresses is now hidden behind a configuration --- include/bbcode.php | 3 +-- include/html2plain.php | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 5b676bbadb..3e3345035e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -673,7 +673,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal //} // Remove all hashtag addresses - if (!$tryoembed) { + if (!$tryoembed AND get_config("system", "remove_hashtags_on_export")) { $pattern = '/#(.*?)<\/a>/is'; $Text = preg_replace($pattern, '#$2', $Text); } @@ -684,4 +684,3 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal return $Text; } - diff --git a/include/html2plain.php b/include/html2plain.php index 80768ffff7..677faa9d58 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -108,8 +108,10 @@ function html2plain($html, $wraplength = 75, $compact = false) $message = str_replace("\r", "", $html); // replace all hashtag addresses - $pattern = '/#(.*?)<\/a>/is'; - $message = preg_replace($pattern, '#$2', $message); + if (get_config("system", "remove_hashtags_on_export")) { + $pattern = '/#(.*?)<\/a>/is'; + $message = preg_replace($pattern, '#$2', $message); + } $doc = new DOMDocument(); $doc->preserveWhiteSpace = false;