1 | 899c899 |
---|
2 | $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', '&#\\1\\2;', $string); |
---|
3 | --- |
---|
4 | $string = preg_replace_callback('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', create_function('$matches', 'return wp_kses_normalize_entities3($matches[2]);'), $string); |
---|
5 | 916c916,942 |
---|
6 | return (($i > 65535) ? "&#$i;" : "&#$i;"); |
---|
7 | --- |
---|
8 | return ( (!valid_unicode($i)) || ($i > 65535) ? "&#$i;" : "&#$i;"); |
---|
9 | } |
---|
10 | |
---|
11 | /** |
---|
12 | * wp_kses_normalize_entities3() - Callback for wp_kses_normalize_entities() for regular expression |
---|
13 | * |
---|
14 | * This function helps wp_kses_normalize_entities() to only accept valid Unicode numeric entities |
---|
15 | * in hex form. |
---|
16 | * |
---|
17 | * @param string $h Hex string of encoded entity |
---|
18 | * @return string Correctly encoded entity |
---|
19 | */ |
---|
20 | function wp_kses_normalize_entities3($hexchars) { |
---|
21 | return ( (!valid_unicode(hexdec($hexchars))) ? "&#x$hexchars;" : "&#x$hexchars;"); |
---|
22 | } |
---|
23 | |
---|
24 | /** |
---|
25 | * valid_unicode() - Helper function to determine if a Unicode value is valid. |
---|
26 | * |
---|
27 | * @param int $i Unicode value |
---|
28 | * @return bool true if the value was a valid Unicode number |
---|
29 | */ |
---|
30 | function valid_unicode($i) { |
---|
31 | return ( $i == 0x9 || $i == 0xa || $i == 0xd || |
---|
32 | ($i >= 0x20 && $i <= 0xd7ff) || |
---|
33 | ($i >= 0xe000 && $i <= 0xfffd) || |
---|
34 | ($i >= 0x10000 && $i <= 0x10ffff) ); |
---|