Make WordPress Core

Ticket #28162: 28162.4.patch

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

     
    289289                        if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
    290290                                $caption = trim( $iptc['2#120'][0] );
    291291                                if ( empty( $meta['title'] ) ) {
     292                                        mbstring_binary_safe_encoding();
    292293                                        // Assume the title is stored in 2:120 if it's short.
    293294                                        if ( strlen( $caption ) < 80 )
    294295                                                $meta['title'] = $caption;
    295296                                        else
    296297                                                $meta['caption'] = $caption;
     298                                        reset_mbstring_encoding();
    297299                                } elseif ( $caption != $meta['title'] ) {
    298300                                        $meta['caption'] = $caption;
    299301                                }
     
    326328                        $meta['title'] = trim( $exif['Title'] );
    327329
    328330                if ( ! empty( $exif['ImageDescription'] ) ) {
     331                        mbstring_binary_safe_encoding();
    329332                        if ( empty( $meta['title'] ) && strlen( $exif['ImageDescription'] ) < 80 ) {
    330333                                // Assume the title is stored in ImageDescription
    331334                                $meta['title'] = trim( $exif['ImageDescription'] );
     
    334337                        } elseif ( trim( $exif['ImageDescription'] ) != $meta['title'] ) {
    335338                                $meta['caption'] = trim( $exif['ImageDescription'] );
    336339                        }
     340                        reset_mbstring_encoding();
    337341                } elseif ( ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) {
    338342                        $meta['caption'] = trim( $exif['Comments'] );
    339343                }
  • src/wp-includes/formatting.php

     
    410410 * @return bool True if $str fits a UTF-8 model, false otherwise.
    411411 */
    412412function seems_utf8($str) {
     413        mbstring_binary_safe_encoding();
    413414        $length = strlen($str);
     415        reset_mbstring_encoding();
    414416        for ($i=0; $i < $length; $i++) {
    415417                $c = ord($str[$i]);
    416418                if ($c < 0x80) $n = 0; # 0bbbbbbb
     
    634636        $num_octets = 1;
    635637        $unicode_length = 0;
    636638
     639        mbstring_binary_safe_encoding();
    637640        $string_length = strlen( $utf8_string );
     641        reset_mbstring_encoding();
     642
    638643        for ($i = 0; $i < $string_length; $i++ ) {
    639644
    640645                $value = ord( $utf8_string[ $i ] );
  • 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                }