svg stuff
This commit is contained in:
@@ -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<$3</text>', $s);
|
||||
$s = preg_replace("/\<text (.*?)\>(.*?)\>(.*?)\<\/text\>/", '<text $1>$2>$3</text>', $s);
|
||||
$s = preg_replace("/\<text (.*?)\>(.*?)\[(.*?)\<\/text\>/", '<text $1>$2[$3</text>', $s);
|
||||
$s = preg_replace("/\<text (.*?)\>(.*?)\](.*?)\<\/text\>/", '<text $1>$2]$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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user