mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
N°6405 - Fix XML displayed corrupted when using \DesignerLongTextField due to usage of \utils::EscapeHtml() without double encoding
This commit is contained in:
@@ -841,17 +841,19 @@ class utilsTest extends ItopTestCase
|
||||
*
|
||||
* @dataProvider escapeHtmlProvider
|
||||
*/
|
||||
public function testEscapeHtml($sInput, $sExpectedEscaped)
|
||||
public function testEscapeHtml($sInput, $sExpectedEscaped, $bDoubleEncode = false)
|
||||
{
|
||||
if (is_null($sExpectedEscaped)) {
|
||||
$sExpectedEscaped = $sInput;
|
||||
}
|
||||
|
||||
$sEscaped = utils::EscapeHtml($sInput);
|
||||
$sEscaped = utils::EscapeHtml($sInput, $bDoubleEncode);
|
||||
self::assertSame($sExpectedEscaped, $sEscaped);
|
||||
|
||||
$sEscapedDecoded = utils::EscapedHtmlDecode($sEscaped);
|
||||
self::assertSame($sInput, $sEscapedDecoded);
|
||||
if (false === $bDoubleEncode) {
|
||||
self::assertSame($sInput, $sEscapedDecoded);
|
||||
}
|
||||
}
|
||||
|
||||
public function escapeHtmlProvider()
|
||||
@@ -859,8 +861,17 @@ class utilsTest extends ItopTestCase
|
||||
return [
|
||||
'no escape' => ['abcdefghijklmnop', null],
|
||||
'&' => ['abcdefghijklmnop&0123456789', 'abcdefghijklmnop&0123456789'],
|
||||
['"double quotes"', '"double quotes"'],
|
||||
["'simple quotes'", ''simple quotes''],
|
||||
'double quotes' => ['"double quotes"', '"double quotes"'],
|
||||
'simple quotes' => ["'simple quotes'", ''simple quotes''],
|
||||
'no double encode' => [
|
||||
'<root><title>Foo & Bar</title></root>',
|
||||
'<root><title>Foo & Bar</title></root>'
|
||||
],
|
||||
'double encode forced (for XML mostly)' => [
|
||||
'<root><title>Foo & Bar</title></root>',
|
||||
'<root><title>Foo &amp; Bar</title></root>',
|
||||
true
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user