diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 1584500188b..156d6f29b0d 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -8333,7 +8333,9 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
}
}
- if (!empty($out) && getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') && $check != 'restricthtmlallowunvalid') {
+ if (!empty($out) && getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') && !in_array($check, array('restricthtmlallowunvalid', 'restricthtmlallowlinkscript'))) {
+ // Tidy can't be used for restricthtmlallowunvalid and restricthtmlallowlinkscript
+ // TODO Try to implement a hack for restricthtmlallowlinkscript by renaming tag and
+ ';
+ $result = dol_htmlwithnojs($s, 1, 'restricthtmlallowlinkscript');
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $sav1;
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $sav2;
+ print __METHOD__." result=".$result."\n";
+ $this->assertEquals($s, $result, 'Test for restricthtmlallowlinkscript');
+
+ // For a string with js and link with restricthtmlallowlinkscript
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
+ $s='
+
+
+ ';
+ $result = dol_htmlwithnojs($s, 1, 'restricthtmlallowlinkscript');
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $sav1;
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $sav2;
+ print __METHOD__." result=".$result."\n";
+ $this->assertEquals($s, $result, 'Test for restricthtmlallowlinkscript');
+
+ // For a string with js and link with restricthtmlallowlinkscript
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0;
+ $s='
+
+
+ ';
+ $result = dol_htmlwithnojs($s, 1, 'restricthtmlallowlinkscript');
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $sav1;
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $sav2;
+ print __METHOD__." result=".$result."\n";
+ $this->assertEquals($s, $result, 'Test for restricthtmlallowlinkscript');
+
return 0;
}