mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-01 11:14:36 +00:00
KSES: Use correct global in wp_kses_xml_named_entities().
This fixes a discrepancy where the the global name used in the function did not match the one declared at the beginning of `kses.php`, and ensures that the function gets the correct array of allowed XML entity names. Includes unit tests. Follow-up to [48072]. Props ovidiul, costdev, peterwilsoncc, SergeyBiryukov. Fixes #54060. git-svn-id: https://develop.svn.wordpress.org/trunk@52229 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1790,4 +1790,110 @@ HTML;
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that XML named entities are encoded correctly.
|
||||
*
|
||||
* @dataProvider data_wp_kses_xml_named_entities
|
||||
*
|
||||
* @ticket 54060
|
||||
* @covers ::wp_kses_xml_named_entities
|
||||
*
|
||||
* @param array $input The input to wp_kses_xml_named_entities().
|
||||
* @param string $expected The expected output.
|
||||
*/
|
||||
public function test_wp_kses_xml_named_entities( $input, $expected ) {
|
||||
$this->assertSame( $expected, wp_kses_xml_named_entities( $input ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for test_wp_kses_xml_named_entities().
|
||||
*
|
||||
* @return array Nested array of input, expected pairs.
|
||||
*/
|
||||
public function data_wp_kses_xml_named_entities() {
|
||||
return array(
|
||||
// Empty string value testing.
|
||||
'empty string' => array(
|
||||
'input' => '',
|
||||
'expected' => '',
|
||||
),
|
||||
|
||||
// Empty string array value testing.
|
||||
'empty string array' => array(
|
||||
'input' => array( '', '' ),
|
||||
'expected' => '',
|
||||
),
|
||||
|
||||
// $allowedxmlentitynames values testing.
|
||||
'amp' => array(
|
||||
'input' => array( '', 'amp' ),
|
||||
'expected' => '&',
|
||||
),
|
||||
'lt' => array(
|
||||
'input' => array( '', 'lt' ),
|
||||
'expected' => '<',
|
||||
),
|
||||
'gt' => array(
|
||||
'input' => array( '', 'gt' ),
|
||||
'expected' => '>',
|
||||
),
|
||||
|
||||
// $allowedentitynames values testing.
|
||||
'nbsp' => array(
|
||||
'input' => array( '', 'nbsp' ),
|
||||
'expected' => utf8_encode( chr( 160 ) ),
|
||||
),
|
||||
'iexcl' => array(
|
||||
'input' => array( '', 'iexcl' ),
|
||||
'expected' => '¡',
|
||||
),
|
||||
'cent' => array(
|
||||
'input' => array( '', 'cent' ),
|
||||
'expected' => '¢',
|
||||
),
|
||||
|
||||
// Some other value testing.
|
||||
'test' => array(
|
||||
'input' => array( '', 'test' ),
|
||||
'expected' => '&test;',
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that KSES globals are defined.
|
||||
*
|
||||
* @dataProvider data_kses_globals_are_defined
|
||||
*
|
||||
* @ticket 54060
|
||||
*
|
||||
* @param string $global The name of the global variable.
|
||||
*/
|
||||
public function test_kses_globals_are_defined( $global ) {
|
||||
$this->assertArrayHasKey( $global, $GLOBALS );
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for test_kses_globals_are_defined().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data_kses_globals_are_defined() {
|
||||
return array(
|
||||
'allowedposttags' => array(
|
||||
'global' => 'allowedposttags',
|
||||
),
|
||||
'allowedtags' => array(
|
||||
'global' => 'allowedtags',
|
||||
),
|
||||
'allowedentitynames' => array(
|
||||
'global' => 'allowedentitynames',
|
||||
),
|
||||
'allowedxmlentitynames' => array(
|
||||
'global' => 'allowedxmlentitynames',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user