aboutsummaryrefslogtreecommitdiffstats
path: root/include/bbcode.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2019-11-07 14:51:29 -0800
committerzotlabs <mike@macgirvin.com>2019-11-07 14:51:29 -0800
commita5826fec251447c1d9c94700183e9ed458127fba (patch)
treeeeecb56411b5a2deadea59aa907a10e4e76a3daa /include/bbcode.php
parent839c6668cfdb12934acf70e67e6721981f99a2f0 (diff)
downloadvolse-hubzilla-a5826fec251447c1d9c94700183e9ed458127fba.tar.gz
volse-hubzilla-a5826fec251447c1d9c94700183e9ed458127fba.tar.bz2
volse-hubzilla-a5826fec251447c1d9c94700183e9ed458127fba.zip
svg stuff
Diffstat (limited to 'include/bbcode.php')
-rw-r--r--include/bbcode.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index bb9144b1d..84f0f3dda 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -4,6 +4,8 @@
* @brief BBCode related functions for parsing, etc.
*/
+use Zotlabs\Lib\SvgSanitizer;
+
require_once('include/oembed.php');
require_once('include/event.php');
require_once('include/zot.php');
@@ -267,6 +269,22 @@ function bb_parse_app($match) {
return Zotlabs\Lib\Apps::app_render($app);
}
+function bb_svg($match) {
+
+ $params = str_replace(['<br>', '&quot;'], [ '', '"'],$match[1]);
+ $Text = str_replace([ '[',']' ], [ '<','>' ], $match[2]);
+
+ $output = '<svg' . (($params) ? $params : ' width="100%" height="480" ') . '>' . str_replace(['<br>', '&quot;', '&nbsp;'], [ '', '"', ' '],$Text) . '</svg>';
+
+ $purify = new SvgSanitizer();
+ $purify->loadXML($output);
+ $purify->sanitize();
+ $output = $purify->saveSVG();
+ $output = preg_replace("/\<\?xml(.*?)\?\>/",'',$output);
+ return $output;
+}
+
+
function bb_parse_element($match) {
$j = json_decode(base64url_decode($match[1]),true);
@@ -1289,6 +1307,9 @@ function bbcode($Text, $options = []) {
$Text = preg_replace_callback("/\[zaudio\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mp3|opus|m4a))\[\/zaudio\]/ism", 'tryzrlaudio', $Text);
}
+ // SVG stuff
+ $Text = preg_replace_callback("/\[svg(.*?)\](.*?)\[\/svg\]/ism", 'bb_svg', $Text);
+
// Try to Oembed
if ($tryoembed) {
if (strpos($Text,'[/video]') !== false) {