Fix style section in html header lost

This commit is contained in:
Laurent Destailleur
2024-10-13 02:01:14 +02:00
parent d3f063b671
commit 740bfe3442
2 changed files with 9 additions and 3 deletions

View File

@@ -8016,11 +8016,12 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
* @param string[] $allowed_tags List of allowed tags to replace the default list
* @param int $allowlink Allow "link" tags (for head html section)
* @param int $allowscript Allow "script" tags (for head html section)
* @param int $allowstyle Allow "style" tags (for head html section)
* @return string String cleaned
*
* @see dol_htmlwithnojs() dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_neverthesehtmltags()
*/
function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0, $allowscript = 0)
function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0, $allowscript = 0, $allowstyle = 0)
{
if (empty($allowed_tags)) {
$allowed_tags = array(
@@ -8045,6 +8046,11 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1,
$allowed_tags[] = "script";
}
}
if ($allowstyle) {
if (!in_array('style', $allowed_tags)) {
$allowed_tags[] = "style";
}
}
$allowed_tags_string = implode("><", $allowed_tags);
$allowed_tags_string = '<'.$allowed_tags_string.'>';
@@ -8421,7 +8427,7 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
// Keep only some html tags and remove also some 'javascript:' strings
if ($check == 'restricthtmlallowlinkscript') {
$out = dol_string_onlythesehtmltags($out, 0, 1, 0, 0, array(), 1, 1);
$out = dol_string_onlythesehtmltags($out, 0, 1, 0, 0, array(), 1, 1, 1);
} elseif ($check == 'restricthtmlallowclass' || $check == 'restricthtmlallowunvalid') {
$out = dol_string_onlythesehtmltags($out, 0, 0, 1);
} else {