From cb59b9b79feaf35a1ce2a131cb03aa50860c3fc2 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Wed, 9 Sep 2015 13:28:16 +0200 Subject: [PATCH] Allowing text-align on wysiwygs [HPN-115] --- h5p.classes.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 4b88008..3a754f0 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2536,6 +2536,7 @@ class H5PContentValidator { public $h5pF; public $h5pC; private $typeMap, $libraries, $dependencies, $nextWeight; + private static $allowed_stylable_tags = array('span', 'p', 'div'); /** * Constructor for the H5PContentValidator @@ -2625,6 +2626,9 @@ class H5PContentValidator { } } + // Aligment is allowed for all wysiwyg texts + $stylePatterns[] = '/^text-align: *(center|left|right);?$/i'; + // Strip invalid HTML tags. $text = $this->filter_xss($text, $tags, $stylePatterns); } @@ -3159,7 +3163,8 @@ class H5PContentValidator { $xhtml_slash = $count ? ' /' : ''; // Clean up attributes. - $attr2 = implode(' ', $this->_filter_xss_attributes($attrlist, ($elem === 'span' ? $this->allowedStyles : FALSE))); + + $attr2 = implode(' ', $this->_filter_xss_attributes($attrlist, (in_array($elem, self::$allowed_stylable_tags) ? $this->allowedStyles : FALSE))); $attr2 = preg_replace('/[<>]/', '', $attr2); $attr2 = strlen($attr2) ? ' ' . $attr2 : '';