mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Html entities use now HTML5. Enhance the Dolibarr WAF. More PHPUnit
tests.
This commit is contained in:
@@ -294,6 +294,46 @@ class SecurityTest extends PHPUnit\Framework\TestCase
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* testDolStringOnlyTheseHtmlTags
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function testDolHTMLEntityDecode()
|
||||
{
|
||||
$stringtotest = 'a : b " c ' d ' e é';
|
||||
$decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES);
|
||||
$this->assertEquals('a : b " c \' d ' e é', $decodedstring, 'Function did not sanitize correclty');
|
||||
|
||||
$stringtotest = 'a : b " c ' d ' e é';
|
||||
$decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES|ENT_HTML5);
|
||||
$this->assertEquals('a : b " c \' d \' e é', $decodedstring, 'Function did not sanitize correclty');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* testDolStringOnlyTheseHtmlTags
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function testDolStringOnlyTheseHtmlTags()
|
||||
{
|
||||
$stringtotest = '<a href="javascript:aaa">bbbڴ';
|
||||
$decodedstring = dol_string_onlythesehtmltags($stringtotest, 1, 1, 1);
|
||||
$this->assertEquals('<a href="aaa">bbbڴ', $decodedstring, 'Function did not sanitize correclty with test 1');
|
||||
|
||||
$stringtotest = '<a href="java'.chr(0).'script:aaa">bbbڴ';
|
||||
$decodedstring = dol_string_onlythesehtmltags($stringtotest, 1, 1, 1);
|
||||
$this->assertEquals('<a href="aaa">bbbڴ', $decodedstring, 'Function did not sanitize correclty with test 2');
|
||||
|
||||
$stringtotest = '<a href="javascript:aaa">bbbڴ';
|
||||
$decodedstring = dol_string_onlythesehtmltags($stringtotest, 1, 1, 1);
|
||||
$this->assertEquals('<a href="aaa">bbbڴ', $decodedstring, 'Function did not sanitize correclty with test 3');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* testGetRandomPassword
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user