forked from Wavyzz/dolibarr
FIX dol_string_onlythesehtmltags can keep html comments
This commit is contained in:
@@ -6521,7 +6521,8 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1,
|
||||
{
|
||||
$allowed_tags = array(
|
||||
"html", "head", "meta", "body", "article", "a", "abbr", "b", "blockquote", "br", "cite", "div", "dl", "dd", "dt", "em", "font", "img", "ins", "hr", "i", "li", "link",
|
||||
"ol", "p", "q", "s", "section", "span", "strike", "strong", "title", "table", "tr", "th", "td", "u", "ul", "sup", "sub", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6"
|
||||
"ol", "p", "q", "s", "section", "span", "strike", "strong", "title", "table", "tr", "th", "td", "u", "ul", "sup", "sub", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6",
|
||||
"comment" // this tags is added to manage comment <!--...--> that are replaced into <comment>...</comment>
|
||||
);
|
||||
if ($allowiframe) {
|
||||
$allowed_tags[] = "iframe";
|
||||
@@ -6534,7 +6535,8 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1,
|
||||
|
||||
$stringtoclean = dol_string_nounprintableascii($stringtoclean, 0);
|
||||
|
||||
$stringtoclean = preg_replace('/<!--[^>]*-->/', '', $stringtoclean);
|
||||
//$stringtoclean = preg_replace('/<!--[^>]*-->/', '', $stringtoclean);
|
||||
$stringtoclean = preg_replace('/<!--([^>]*)-->/', '<comment>\1</comment>', $stringtoclean);
|
||||
|
||||
$stringtoclean = preg_replace('/:/i', ':', $stringtoclean);
|
||||
$stringtoclean = preg_replace('/:|�+58|:/i', '', $stringtoclean); // refused string ':' encoded (no reason to have a : encoded like this) to disable 'javascript:...'
|
||||
@@ -6557,6 +6559,9 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1,
|
||||
|
||||
$temp = str_replace('__!DOCTYPE_HTML__', '<!DOCTYPE html>', $temp); // Restore the DOCTYPE
|
||||
|
||||
$temp = preg_replace('/<comment>([^>]*)<\/comment>/', '<!--\1-->', $temp); // Restore html comments
|
||||
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user