Changeset 8386
- Timestamp:
- 07/21/2008 03:21:09 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/kses.php
r8384 r8386 274 274 'ul' => array ( 275 275 'class' => array (), 276 'style' => array (), 276 'style' => array (), 277 277 'type' => array ()), 278 278 'ol' => array ( 279 279 'class' => array (), 280 280 'start' => array (), 281 'style' => array (), 281 'style' => array (), 282 282 'type' => array ()), 283 283 'var' => array ()); … … 912 912 $string = preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', '&\\1;', $string); 913 913 $string = preg_replace_callback('/&#0*([0-9]{1,5});/', create_function('$matches', 'return wp_kses_normalize_entities2($matches[1]);'), $string); 914 $string = preg_replace ('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string);914 $string = preg_replace_callback('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', create_function('$matches', 'return wp_kses_normalize_entities3($matches[2]);'), $string); 915 915 916 916 return $string; … … 929 929 */ 930 930 function wp_kses_normalize_entities2($i) { 931 return (($i > 65535) ? "&#$i;" : "&#$i;"); 931 return ( (!valid_unicode($i)) || ($i > 65535) ? "&#$i;" : "&#$i;"); 932 } 933 934 /** 935 * wp_kses_normalize_entities3() - Callback for wp_kses_normalize_entities() for regular expression 936 * 937 * This function helps wp_kses_normalize_entities() to only accept valid Unicode numeric entities 938 * in hex form. 939 * 940 * @param string $h Hex string of encoded entity 941 * @return string Correctly encoded entity 942 */ 943 function wp_kses_normalize_entities3($hexchars) { 944 return ( (!valid_unicode(hexdec($hexchars))) ? "&#x$hexchars;" : "&#x$hexchars;"); 945 } 946 947 /** 948 * valid_unicode() - Helper function to determine if a Unicode value is valid. 949 * 950 * @param int $i Unicode value 951 * @return bool true if the value was a valid Unicode number 952 */ 953 function valid_unicode($i) { 954 return ( $i == 0x9 || $i == 0xa || $i == 0xd || 955 ($i >= 0x20 && $i <= 0xd7ff) || 956 ($i >= 0xe000 && $i <= 0xfffd) || 957 ($i >= 0x10000 && $i <= 0x10ffff) ); 932 958 } 933 959
Note: See TracChangeset
for help on using the changeset viewer.