Make WordPress Core

Ticket #28162: 28162.5.patch

File 28162.5.patch, 3.7 KB (added by SergeyBiryukov, 11 years ago)
  • src/wp-admin/includes/image.php

     
    290290                                $caption = trim( $iptc['2#120'][0] );
    291291                                if ( empty( $meta['title'] ) ) {
    292292                                        // Assume the title is stored in 2:120 if it's short.
    293                                         if ( strlen( $caption ) < 80 )
     293                                        if ( mbstring_binary_safe_strlen( $caption ) < 80 )
    294294                                                $meta['title'] = $caption;
    295295                                        else
    296296                                                $meta['caption'] = $caption;
     
    327327                }
    328328
    329329                if ( ! empty( $exif['ImageDescription'] ) ) {
    330                         if ( empty( $meta['title'] ) && strlen( $exif['ImageDescription'] ) < 80 ) {
     330                        if ( empty( $meta['title'] ) && mbstring_binary_safe_strlen( $exif['ImageDescription'] ) < 80 ) {
    331331                                // Assume the title is stored in ImageDescription
    332332                                $meta['title'] = trim( $exif['ImageDescription'] );
    333333                                if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] ) {
  • src/wp-includes/formatting.php

     
    410410 * @return bool True if $str fits a UTF-8 model, false otherwise.
    411411 */
    412412function seems_utf8($str) {
    413         $length = strlen($str);
     413        $length = mbstring_binary_safe_strlen($str);
    414414        for ($i=0; $i < $length; $i++) {
    415415                $c = ord($str[$i]);
    416416                if ($c < 0x80) $n = 0; # 0bbbbbbb
     
    634634        $num_octets = 1;
    635635        $unicode_length = 0;
    636636
    637         $string_length = strlen( $utf8_string );
     637        $string_length = mbstring_binary_safe_strlen( $utf8_string );
    638638        for ($i = 0; $i < $string_length; $i++ ) {
    639639
    640640                $value = ord( $utf8_string[ $i ] );
  • src/wp-includes/functions.php

     
    44374437}
    44384438
    44394439/**
     4440 * Uses a binary-safe encoding to get string length in bytes if func_overload is enabled.
     4441 *
     4442 * @see mbstring_binary_safe_encoding()
     4443 *
     4444 * @since 4.0.0
     4445 */
     4446function mbstring_binary_safe_strlen( $string ) {
     4447        mbstring_binary_safe_encoding();
     4448        $length = strlen( $string );
     4449        reset_mbstring_encoding();
     4450
     4451        return $length;
     4452}
     4453
     4454/**
    44404455 * Alternative to filter_var( $var, FILTER_VALIDATE_BOOLEAN )
    44414456 *
    44424457 * @since 4.0.0
  • src/wp-includes/pomo/mo.php

     
    7575                $current_addr++;
    7676                $originals_table = chr(0);
    7777
     78                $reader = new POMO_Reader();
     79
    7880                foreach($entries as $entry) {
    7981                        $originals_table .= $this->export_original($entry) . chr(0);
    80                         $length = strlen($this->export_original($entry));
     82                        $length = $reader->strlen($this->export_original($entry));
    8183                        fwrite($fh, pack('VV', $length, $current_addr));
    8284                        $current_addr += $length + 1; // account for the NULL byte after
    8385                }
    8486
    8587                $exported_headers = $this->export_headers();
    86                 fwrite($fh, pack('VV', strlen($exported_headers), $current_addr));
     88                fwrite($fh, pack('VV', $reader->strlen($exported_headers), $current_addr));
    8789                $current_addr += strlen($exported_headers) + 1;
    8890                $translations_table = $exported_headers . chr(0);
    8991
    9092                foreach($entries as $entry) {
    9193                        $translations_table .= $this->export_translations($entry) . chr(0);
    92                         $length = strlen($this->export_translations($entry));
     94                        $length = $reader->strlen($this->export_translations($entry));
    9395                        fwrite($fh, pack('VV', $length, $current_addr));
    9496                        $current_addr += $length + 1;
    9597                }