Make WordPress Core

Changeset 43635


Ignore:
Timestamp:
09/12/2018 06:10:42 AM (6 years ago)
Author:
ocean90
Message:

I18N: In the POMO library, replace chr() calls for static values with their string representation.

Props ccismaru, ocean90.
Fixes #17128.

Location:
trunk/src/wp-includes/pomo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pomo/entry.php

    r42343 r43635  
    8282
    8383            // Prepend context and EOT, like in MO files
    84             $key = ! $this->context ? $this->singular : $this->context . chr( 4 ) . $this->singular;
     84            $key = ! $this->context ? $this->singular : $this->context . "\4" . $this->singular;
    8585            // Standardize on \n line endings
    8686            $key = str_replace( array( "\r\n", "\r" ), "\n", $key );
  • trunk/src/wp-includes/pomo/mo.php

    r43571 r43635  
    125125            fwrite( $fh, pack( 'VV', 0, $current_addr ) );
    126126            $current_addr++;
    127             $originals_table = chr( 0 );
     127            $originals_table = "\0";
    128128
    129129            $reader = new POMO_Reader();
    130130
    131131            foreach ( $entries as $entry ) {
    132                 $originals_table .= $this->export_original( $entry ) . chr( 0 );
     132                $originals_table .= $this->export_original( $entry ) . "\0";
    133133                $length           = $reader->strlen( $this->export_original( $entry ) );
    134134                fwrite( $fh, pack( 'VV', $length, $current_addr ) );
     
    139139            fwrite( $fh, pack( 'VV', $reader->strlen( $exported_headers ), $current_addr ) );
    140140            $current_addr      += strlen( $exported_headers ) + 1;
    141             $translations_table = $exported_headers . chr( 0 );
     141            $translations_table = $exported_headers . "\0";
    142142
    143143            foreach ( $entries as $entry ) {
    144                 $translations_table .= $this->export_translations( $entry ) . chr( 0 );
     144                $translations_table .= $this->export_translations( $entry ) . "\0";
    145145                $length              = $reader->strlen( $this->export_translations( $entry ) );
    146146                fwrite( $fh, pack( 'VV', $length, $current_addr ) );
     
    161161            $exported = $entry->singular;
    162162            if ( $entry->is_plural ) {
    163                 $exported .= chr( 0 ) . $entry->plural;
     163                $exported .= "\0" . $entry->plural;
    164164            }
    165165            if ( $entry->context ) {
    166                 $exported = $entry->context . chr( 4 ) . $exported;
     166                $exported = $entry->context . "\4" . $exported;
    167167            }
    168168            return $exported;
     
    175175        function export_translations( $entry ) {
    176176            //TODO: warnings for control characters
    177             return $entry->is_plural ? implode( chr( 0 ), $entry->translations ) : $entry->translations[0];
     177            return $entry->is_plural ? implode( "\0", $entry->translations ) : $entry->translations[0];
    178178        }
    179179
     
    311311        function &make_entry( $original, $translation ) {
    312312            $entry = new Translation_Entry();
    313             // look for context
    314             $parts = explode( chr( 4 ), $original );
     313            // Look for context, separated by \4.
     314            $parts = explode( "\4", $original );
    315315            if ( isset( $parts[1] ) ) {
    316316                $original       = $parts[1];
     
    318318            }
    319319            // look for plural original
    320             $parts           = explode( chr( 0 ), $original );
     320            $parts           = explode( "\0", $original );
    321321            $entry->singular = $parts[0];
    322322            if ( isset( $parts[1] ) ) {
     
    325325            }
    326326            // plural translations are also separated by \0
    327             $entry->translations = explode( chr( 0 ), $translation );
     327            $entry->translations = explode( "\0", $translation );
    328328            return $entry;
    329329        }
Note: See TracChangeset for help on using the changeset viewer.