mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:35:12 +00:00
svg mopup
This commit is contained in:
parent
73ce177eec
commit
7a9af29636
3 changed files with 12 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3449,14 +3449,17 @@ 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 = 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue