Make WordPress Core

Ticket #31328: 31328.2.patch

File 31328.2.patch, 2.3 KB (added by SergeyBiryukov, 10 years ago)
  • src/wp-includes/formatting.php

     
    785785                        $unicode .= chr($value);
    786786                        $unicode_length++;
    787787                } else {
    788                         if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
     788                        if ( count( $values ) == 0 ) {
     789                                if ( $value < 224 ) {
     790                                        $num_octets = 2;
     791                                } elseif ( $value < 240 ) {
     792                                        $num_octets = 3;
     793                                } else {
     794                                        $num_octets = 4;
     795                                }
     796                        }
    789797
    790798                        $values[] = $value;
    791799
     
    792800                        if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )
    793801                                break;
    794802                        if ( count( $values ) == $num_octets ) {
    795                                 if ($num_octets == 3) {
    796                                         $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
    797                                         $unicode_length += 9;
    798                                 } else {
    799                                         $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
    800                                         $unicode_length += 6;
     803                                for ( $j = 0; $j < $num_octets; $j++ ) {
     804                                        $unicode .= '%' . dechex( $values[ $j ] );
    801805                                }
    802806
     807                                $unicode_length += $num_octets * 3;
     808
    803809                                $values = array();
    804810                                $num_octets = 1;
    805811                        }
     
    12661272        // Restore octets.
    12671273        $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
    12681274
     1275        if ( 'save' === $context ) {
     1276                // Strip Emoticons
     1277                $title = preg_replace( '/[\x{1F600}-\x{1F64F}]/u', '', $title );
     1278
     1279                // Strip Miscellaneous Symbols and Pictographs
     1280                $title = preg_replace( '/[\x{1F300}-\x{1F5FF}]/u', '', $title );
     1281
     1282                // Strip Transport And Map Symbols
     1283                $title = preg_replace( '/[\x{1F680}-\x{1F6FF}]/u', '', $title );
     1284
     1285                // Strip Miscellaneous Symbols
     1286                $title = preg_replace( '/[\x{2600}-\x{26FF}]/u', '', $title );
     1287
     1288                // Strip Dingbats
     1289                $title = preg_replace( '/[\x{2700}-\x{27BF}]/u', '', $title );
     1290        }
     1291
    12691292        if (seems_utf8($title)) {
    12701293                if (function_exists('mb_strtolower')) {
    12711294                        $title = mb_strtolower($title, 'UTF-8');
     
    12771300        $title = preg_replace('/&.+?;/', '', $title); // kill entities
    12781301        $title = str_replace('.', '-', $title);
    12791302
    1280         if ( 'save' == $context ) {
     1303        if ( 'save' === $context ) {
    12811304                // Convert nbsp, ndash and mdash to hyphens
    12821305                $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
    12831306