Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue #17526: Filter html_entity_decode at save (#2017)
Co-authored-by: encuestabizdevgit <devgit@encuesta.biz>
- Loading branch information
1 parent
f044289
commit 6da7e44
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace ls\tests; | ||
|
||
/** | ||
* Test LSYii_Validators class. | ||
*/ | ||
class LSYiiValidatorsTest extends TestBaseClass | ||
{ | ||
/** | ||
* Test filtering of html_entity_decode. | ||
*/ | ||
public function testHtmlEntityDecodeFilter() | ||
{ | ||
// First, we define the cases to test. Array keys are the strings to filter, and values are the expected result | ||
$cases = [ | ||
"html_entity_decode('&')" => "html_entity_decode('&')", // Not an expression, so it shouldn't be changed. | ||
"{html_entity_decode('&')}" => "{('&')}", // Used as a function in an expression, so it should be removed. | ||
"{join(\"{\",'html_entity_decode(\"&amp;\")',\"}\")}" => "{join(\"{\",'html_entity_decode(\"&amp;\")',\"}\")}", // Inside a function but as a string, so it's not removed. | ||
]; | ||
|
||
$validator = new \LSYii_Validators(); | ||
|
||
// Test each case | ||
foreach ($cases as $string => $expected) { | ||
$actual = $validator->xssFilter($string); | ||
$this->assertEquals($expected, $actual); | ||
} | ||
} | ||
} |