Changeset 52229
- Timestamp:
- 11/21/2021 05:15:26 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/kses.php
r52128 r52229 460 460 461 461 /** 462 * @var string[] $allowedentitynames Array of KSES allowed HTML entit ity names.462 * @var string[] $allowedentitynames Array of KSES allowed HTML entity names. 463 463 * @since 1.0.0 464 464 */ … … 720 720 721 721 /** 722 * @var string[] $allowedxmlentitynames Array of KSES allowed XML entit ity names.722 * @var string[] $allowedxmlentitynames Array of KSES allowed XML entity names. 723 723 * @since 5.5.0 724 724 */ 725 $allowedxml namedentities = array(725 $allowedxmlentitynames = array( 726 726 'amp', 727 727 'lt', … … 1907 1907 */ 1908 1908 function wp_kses_xml_named_entities( $matches ) { 1909 global $allowedentitynames, $allowedxml namedentities;1909 global $allowedentitynames, $allowedxmlentitynames; 1910 1910 1911 1911 if ( empty( $matches[1] ) ) { … … 1915 1915 $i = $matches[1]; 1916 1916 1917 if ( in_array( $i, $allowedxml namedentities, true ) ) {1917 if ( in_array( $i, $allowedxmlentitynames, true ) ) { 1918 1918 return "&$i;"; 1919 1919 } elseif ( in_array( $i, $allowedentitynames, true ) ) { -
trunk/tests/phpunit/tests/kses.php
r52010 r52229 1791 1791 return $return_data; 1792 1792 } 1793 1794 /** 1795 * Test that XML named entities are encoded correctly. 1796 * 1797 * @dataProvider data_wp_kses_xml_named_entities 1798 * 1799 * @ticket 54060 1800 * @covers ::wp_kses_xml_named_entities 1801 * 1802 * @param array $input The input to wp_kses_xml_named_entities(). 1803 * @param string $expected The expected output. 1804 */ 1805 public function test_wp_kses_xml_named_entities( $input, $expected ) { 1806 $this->assertSame( $expected, wp_kses_xml_named_entities( $input ) ); 1807 } 1808 1809 /** 1810 * Data provider for test_wp_kses_xml_named_entities(). 1811 * 1812 * @return array Nested array of input, expected pairs. 1813 */ 1814 public function data_wp_kses_xml_named_entities() { 1815 return array( 1816 // Empty string value testing. 1817 'empty string' => array( 1818 'input' => '', 1819 'expected' => '', 1820 ), 1821 1822 // Empty string array value testing. 1823 'empty string array' => array( 1824 'input' => array( '', '' ), 1825 'expected' => '', 1826 ), 1827 1828 // $allowedxmlentitynames values testing. 1829 'amp' => array( 1830 'input' => array( '', 'amp' ), 1831 'expected' => '&', 1832 ), 1833 'lt' => array( 1834 'input' => array( '', 'lt' ), 1835 'expected' => '<', 1836 ), 1837 'gt' => array( 1838 'input' => array( '', 'gt' ), 1839 'expected' => '>', 1840 ), 1841 1842 // $allowedentitynames values testing. 1843 'nbsp' => array( 1844 'input' => array( '', 'nbsp' ), 1845 'expected' => utf8_encode( chr( 160 ) ), 1846 ), 1847 'iexcl' => array( 1848 'input' => array( '', 'iexcl' ), 1849 'expected' => '¡', 1850 ), 1851 'cent' => array( 1852 'input' => array( '', 'cent' ), 1853 'expected' => '¢', 1854 ), 1855 1856 // Some other value testing. 1857 'test' => array( 1858 'input' => array( '', 'test' ), 1859 'expected' => '&test;', 1860 ), 1861 1862 ); 1863 } 1864 1865 /** 1866 * Test that KSES globals are defined. 1867 * 1868 * @dataProvider data_kses_globals_are_defined 1869 * 1870 * @ticket 54060 1871 * 1872 * @param string $global The name of the global variable. 1873 */ 1874 public function test_kses_globals_are_defined( $global ) { 1875 $this->assertArrayHasKey( $global, $GLOBALS ); 1876 } 1877 1878 /** 1879 * Data provider for test_kses_globals_are_defined(). 1880 * 1881 * @return array 1882 */ 1883 public function data_kses_globals_are_defined() { 1884 return array( 1885 'allowedposttags' => array( 1886 'global' => 'allowedposttags', 1887 ), 1888 'allowedtags' => array( 1889 'global' => 'allowedtags', 1890 ), 1891 'allowedentitynames' => array( 1892 'global' => 'allowedentitynames', 1893 ), 1894 'allowedxmlentitynames' => array( 1895 'global' => 'allowedxmlentitynames', 1896 ), 1897 ); 1898 } 1793 1899 }
Note: See TracChangeset
for help on using the changeset viewer.