forked from Wavyzz/dolibarr
Add phpunit case
This commit is contained in:
@@ -8118,6 +8118,8 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
|
|||||||
// like '<h1>Foo</h1><p>bar</p>' that wrongly ends up, without the trick, with '<h1>Foo<p>bar</p></h1>'
|
// like '<h1>Foo</h1><p>bar</p>' that wrongly ends up, without the trick, with '<h1>Foo<p>bar</p></h1>'
|
||||||
// like 'abc' that wrongly ends up, without the trick, with '<p>abc</p>'
|
// like 'abc' that wrongly ends up, without the trick, with '<p>abc</p>'
|
||||||
|
|
||||||
|
// TODO Must accept emoji with MAIN_RESTRICTHTML_ONLY_VALID_HTML...
|
||||||
|
|
||||||
if (dol_textishtml($out)) {
|
if (dol_textishtml($out)) {
|
||||||
$out = '<?xml encoding="UTF-8"><div class="tricktoremove">'.$out.'</div>';
|
$out = '<?xml encoding="UTF-8"><div class="tricktoremove">'.$out.'</div>';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1110,6 +1110,43 @@ class SecurityTest extends CommonClassTest
|
|||||||
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
|
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testDolHtmlWithNoJs()
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function testDolHtmlWithNoJs()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$sav1 = $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML;
|
||||||
|
$sav2 = $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY;
|
||||||
|
|
||||||
|
// Test with an emoji
|
||||||
|
$test = 'abc ✅ def';
|
||||||
|
|
||||||
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
|
||||||
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
|
||||||
|
$result = dol_htmlwithnojs($test);
|
||||||
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $sav1;
|
||||||
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $sav2;
|
||||||
|
|
||||||
|
print __METHOD__." result for dol_htmlwithnojs and MAIN_RESTRICTHTML_ONLY_VALID_HTML=0 with emoji = ".$result."\n";
|
||||||
|
$this->assertEquals($test, $result, 'dol_htmlwithnojs failed with an emoji when MAIN_RESTRICTHTML_ONLY_VALID_HTML=0');
|
||||||
|
|
||||||
|
/*
|
||||||
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
|
||||||
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
|
||||||
|
$result = dol_htmlwithnojs($test);
|
||||||
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = $sav1;
|
||||||
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = $sav2;
|
||||||
|
|
||||||
|
print __METHOD__." result for dol_htmlwithnojs and MAIN_RESTRICTHTML_ONLY_VALID_HTML=1 with emoji = ".$result."\n";
|
||||||
|
$this->assertEquals($test, $result, 'dol_htmlwithnojs failed with an emoji when MAIN_RESTRICTHTML_ONLY_VALID_HTML=1');
|
||||||
|
*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testDolPrintHTML.
|
* testDolPrintHTML.
|
||||||
|
|||||||
Reference in New Issue
Block a user