Ticket #6583: bug6583.patch
| File bug6583.patch, 2.2 KB (added by schiller, 4 years ago) |
|---|
-
kses.php
271 271 'u' => array(), 272 272 'ul' => array ( 273 273 'class' => array (), 274 'style' => array (), 274 'style' => array (), 275 275 'type' => array ()), 276 276 'ol' => array ( 277 277 'class' => array (), 278 278 'start' => array (), 279 'style' => array (), 279 'style' => array (), 280 280 'type' => array ()), 281 281 'var' => array ()); 282 282 /** … … 896 896 897 897 $string = preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $string); 898 898 $string = preg_replace_callback('/&#0*([0-9]{1,5});/', create_function('$matches', 'return wp_kses_normalize_entities2($matches[1]);'), $string); 899 $string = preg_replace ('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);899 $string = preg_replace_callback('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', create_function('$matches', 'return wp_kses_normalize_entities3($matches[2]);'), $string); 900 900 901 901 return $string; 902 902 } … … 913 913 * @return string Correctly encoded entity 914 914 */ 915 915 function wp_kses_normalize_entities2($i) { 916 return ( ($i > 65535) ? "&#$i;" : "&#$i;");916 return ( (!valid_unicode($i)) || ($i > 65535) ? "&#$i;" : "&#$i;"); 917 917 } 918 918 919 919 /** 920 * wp_kses_normalize_entities3() - Callback for wp_kses_normalize_entities() for regular expression 921 * 922 * This function helps wp_kses_normalize_entities() to only accept valid Unicode numeric entities 923 * in hex form. 924 * 925 * @param string $h Hex string of encoded entity 926 * @return string Correctly encoded entity 927 */ 928 function wp_kses_normalize_entities3($hexchars) { 929 return ( (!valid_unicode(hexdec($hexchars))) ? "&#x$hexchars;" : "&#x$hexchars;"); 930 } 931 932 /** 933 * valid_unicode() - Helper function to determine if a Unicode value is valid. 934 * 935 * @param int $i Unicode value 936 * @return bool true if the value was a valid Unicode number 937 */ 938 function valid_unicode($i) { 939 return ( $i == 0x9 || $i == 0xa || $i == 0xd || 940 ($i >= 0x20 && $i <= 0xd7ff) || 941 ($i >= 0xe000 && $i <= 0xfffd) || 942 ($i >= 0x10000 && $i <= 0x10ffff) ); 943 } 944 945 /** 920 946 * wp_kses_decode_entities() - Convert all entities to their character counterparts. 921 947 * 922 948 * This function decodes numeric HTML entities (A and A). It
