aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-12-13 20:01:38 -0800
committerzotlabs <mike@macgirvin.com>2016-12-13 20:01:38 -0800
commit0394a3e93957b5bb6574ca95e290e414ed049404 (patch)
tree64763a081485babec1a5ca98ca87cbdf758ced2f /include/text.php
parent8e400e9e40dc115d81bd03581ea6da3badec5a19 (diff)
downloadvolse-hubzilla-0394a3e93957b5bb6574ca95e290e414ed049404.tar.gz
volse-hubzilla-0394a3e93957b5bb6574ca95e290e414ed049404.tar.bz2
volse-hubzilla-0394a3e93957b5bb6574ca95e290e414ed049404.zip
tag and mention handling in private mail (which required refactoring the bbcode cleanup stuff in mod_item)
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php48
1 files changed, 47 insertions, 1 deletions
diff --git a/include/text.php b/include/text.php
index b25eb8e46..e014024c2 100644
--- a/include/text.php
+++ b/include/text.php
@@ -3061,4 +3061,50 @@ function create_table_from_array($table, $arr) {
}
return $r;
-} \ No newline at end of file
+}
+
+
+
+function cleanup_bbcode($body) {
+
+
+ /**
+ * fix naked links by passing through a callback to see if this is a hubzilla site
+ * (already known to us) which will get a zrl, otherwise link with url, add bookmark tag to both.
+ * First protect any url inside certain bbcode tags so we don't double link it.
+ */
+
+ $body = preg_replace_callback('/\[code(.*?)\[\/(code)\]/ism','\red_escape_codeblock',$body);
+ $body = preg_replace_callback('/\[url(.*?)\[\/(url)\]/ism','\red_escape_codeblock',$body);
+ $body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','\red_escape_codeblock',$body);
+
+
+ $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\
++\,\(\)]+)/ism", 'nakedoembed', $body);
+ $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\
++\,\(\)]+)/ism", '\red_zrl_callback', $body);
+
+ $body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','\red_unescape_codeblock',$body);
+ $body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','\red_unescape_codeblock',$body);
+ $body = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism','\red_unescape_codeblock',$body);
+
+
+ // fix any img tags that should be zmg
+
+ $body = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','\red_zrlify_img_callback',$body);
+
+
+ $body = bb_translate_video($body);
+
+ /**
+ * Fold multi-line [code] sequences
+ */
+
+ $body = preg_replace('/\[\/code\]\s*\[code\]/ism',"\n",$body);
+
+ $body = scale_external_images($body,false);
+
+
+ return $body;
+
+}