Prepare \MailSo\Base\HtmlUtils::ClearHtml for improvements

This commit is contained in:
djmaze 2020-12-18 11:11:54 +01:00
parent 9f9685b4eb
commit 1cf7344ef5
2 changed files with 10 additions and 10 deletions

View file

@ -680,11 +680,11 @@ abstract class HtmlUtils
if ($sAttrName && $oAttr) if ($sAttrName && $oAttr)
{ {
$sAttrNameLower = \trim(\strtolower($sAttrName)); $sAttrNameLower = \trim(\strtolower($sAttrName));
if ($aHtmlAllowedAttributes && !\in_array($sAttrNameLower, $aHtmlAllowedAttributes)) if (($aHtmlAllowedAttributes && !\in_array($sAttrNameLower, $aHtmlAllowedAttributes))
{ || 'on' === \substr($sAttrNameLower, 0, 2)
$sAttrsForRemove[] = $sAttrName; // || 'data-' === \substr($sAttrNameLower, 0, 5)
} // || \strpos($sAttrNameLower, ':')
else if ('on' === \substr($sAttrNameLower, 0, 2) || in_array($sAttrNameLower, array( || \in_array($sAttrNameLower, array(
'id', 'class', 'contenteditable', 'designmode', 'formaction', 'manifest', 'action', 'id', 'class', 'contenteditable', 'designmode', 'formaction', 'manifest', 'action',
'data-bind', 'data-reactid', 'xmlns', 'srcset', 'data-x-skip-style', 'data-bind', 'data-reactid', 'xmlns', 'srcset', 'data-x-skip-style',
'fscommand', 'seeksegmenttime' 'fscommand', 'seeksegmenttime'
@ -756,8 +756,8 @@ abstract class HtmlUtils
$sH = $oElement->hasAttribute('height') $sH = $oElement->hasAttribute('height')
? \trim($oElement->getAttribute('height')) : ''; ? \trim($oElement->getAttribute('height')) : '';
// $sW = $oElement->hasAttribute('width') // $sW = $oElement->hasAttribute('width')
// ? \trim($oElement->getAttribute('width')) : ''; // ? \trim($oElement->getAttribute('width')) : '';
$sStyles = $oElement->hasAttribute('style') $sStyles = $oElement->hasAttribute('style')
? \preg_replace('/[\s]+/', '', \trim(\trim(\trim($oElement->getAttribute('style')), ';'))) : ''; ? \preg_replace('/[\s]+/', '', \trim(\trim(\trim($oElement->getAttribute('style')), ';'))) : '';

View file

@ -112,8 +112,6 @@ class Api
if (static::Config()->Get('labs', 'strict_html_parser', true)) if (static::Config()->Get('labs', 'strict_html_parser', true))
{ {
\MailSo\Config::$HtmlStrictAllowedAttributes = array( \MailSo\Config::$HtmlStrictAllowedAttributes = array(
// rainloop
'data-wrp',
// defaults // defaults
'name', 'name',
'dir', 'lang', 'style', 'title', 'dir', 'lang', 'style', 'title',
@ -148,8 +146,10 @@ class Api
'selected', 'label', 'selected', 'label',
// table // table
'cols', 'rows', 'frame', 'rules', 'summary', 'cellpadding', 'cellspacing', 'cols', 'rows', 'frame', 'rules', 'summary', 'cellpadding', 'cellspacing',
// th
'abbr', 'scope',
// td // td
'abbr', 'axis', 'colspan', 'rowspan', 'headers', 'nowrap' 'axis', 'colspan', 'rowspan', 'headers', 'nowrap'
); );
} }
} }