aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorZot <mike@macgirvin.com>2019-11-08 10:47:00 +0100
committerMario <mario@mariovavti.com>2019-11-08 10:47:00 +0100
commita6165c00ce286a9b9ee84bb104c1b5d9d944823a (patch)
treeeeecb56411b5a2deadea59aa907a10e4e76a3daa /include/text.php
parente9a9fc50501d63998203c51e8e0d5ce4a3fcf598 (diff)
downloadvolse-hubzilla-a6165c00ce286a9b9ee84bb104c1b5d9d944823a.tar.gz
volse-hubzilla-a6165c00ce286a9b9ee84bb104c1b5d9d944823a.tar.bz2
volse-hubzilla-a6165c00ce286a9b9ee84bb104c1b5d9d944823a.zip
svg stuff
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index 54ad9ec7a..2496ca934 100644
--- a/include/text.php
+++ b/include/text.php
@@ -9,6 +9,8 @@ use Michelf\MarkdownExtra;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
+use Zotlabs\Lib\SvgSanitizer;
+
require_once("include/bbcode.php");
// random string, there are 86 characters max in text mode, 128 for hex
@@ -3648,3 +3650,23 @@ function new_uuid() {
return $hash;
}
+
+
+function svg2bb($s) {
+
+ $s = preg_replace("/\<text (.*?)\>(.*?)\<(.*?)\<\/text\>/", '<text $1>$2&lt;$3</text>', $s);
+ $s = preg_replace("/\<text (.*?)\>(.*?)\>(.*?)\<\/text\>/", '<text $1>$2&gt;$3</text>', $s);
+ $s = preg_replace("/\<text (.*?)\>(.*?)\[(.*?)\<\/text\>/", '<text $1>$2&#91;$3</text>', $s);
+ $s = preg_replace("/\<text (.*?)\>(.*?)\](.*?)\<\/text\>/", '<text $1>$2&#93;$3</text>', $s);
+ $s = utf8_encode($s);
+ $purify = new SvgSanitizer();
+ if ($purify->loadXML($s)) {
+ $purify->sanitize();
+ $output = $purify->saveSVG();
+ $output = preg_replace("/\<\?xml(.*?)\>/",'',$output);
+ $output = preg_replace("/\<\!\-\-(.*?)\-\-\>/",'',$output);
+ $output = str_replace(['<','>'],['[',']'],$output);
+ return $output;
+ }
+ return EMPTY_STR;
+}