svg mopup

This commit is contained in:
zotlabs 2019-11-06 02:15:38 -08:00
parent 73ce177eec
commit 7a9af29636
3 changed files with 12 additions and 3 deletions

View file

@ -60,7 +60,7 @@ class SvgSanitizer {
);
function __construct() {
$this->xmlDoc = new DOMDocument();
$this->xmlDoc = new DOMDocument('1.0','UTF-8');
$this->xmlDoc->preserveWhiteSpace = false;
libxml_use_internal_errors(true);
}

View file

@ -132,6 +132,12 @@ class Wall_attach extends Controller {
if ($bb) {
$s .= "\n\n" . $bb;
}
else {
logger('empty return from svgbb');
}
}
else {
logger('unable to read svg data file: ' . 'store/' . $channel['channel_address'] . '/' . $r['data']['os_path']);
}
}

View file

@ -3449,14 +3449,17 @@ 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 = 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);
$output = str_replace('/]',']',$output);
return $output;
}
return EMPTY_STR;}
return EMPTY_STR;
}