diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index d27c4dac376..30edeac0d32 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -76,6 +76,9 @@ function dolStripPhpCode($str, $replacewith = '') function dolKeepOnlyPhpCode($str) { $str = str_replace('assertEquals($result, 1, 'checkPHPCode did not detect the string was dangerous'); } + + /** + * testDolKeepOnlyPhpCode + * + * @return void + */ + public function testDolKeepOnlyPhpCode() + { + $s = 'HTML content and more HTML content'; + $result = dolKeepOnlyPhpCode($s); + print __METHOD__." result dolKeepOnlyPhpCode=".$result."\n"; + $this->assertEquals('', $result, 'dolKeepOnlyPhpCode did extract the correct string'); + + $s = 'HTML content and more HTML content'; + $result = dolKeepOnlyPhpCode($s); + print __METHOD__." result dolKeepOnlyPhpCode=".$result."\n"; + $this->assertEquals('', $result, 'dolKeepOnlyPhpCode did extract the correct string'); + + $s = 'HTML content and more HTML content'; + $result = dolKeepOnlyPhpCode($s); + print __METHOD__." result dolKeepOnlyPhpCode=".$result."\n"; + $this->assertEquals('', $result, 'dolKeepOnlyPhpCode did extract the correct string'); + } }