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

Props ccismaru, ocean90.
Fixes #17128.
Built from https://develop.svn.wordpress.org/trunk@43635


git-svn-id: http://core.svn.wordpress.org/trunk@43464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2018-09-12 06:11:26 +00:00
parent 836d2bf421
commit a7bb083120
3 changed files with 13 additions and 13 deletions

View File

@ -81,7 +81,7 @@ if ( ! class_exists( 'Translation_Entry', false ) ) :
} }
// Prepend context and EOT, like in MO files // Prepend context and EOT, like in MO files
$key = ! $this->context ? $this->singular : $this->context . chr( 4 ) . $this->singular; $key = ! $this->context ? $this->singular : $this->context . "\4" . $this->singular;
// Standardize on \n line endings // Standardize on \n line endings
$key = str_replace( array( "\r\n", "\r" ), "\n", $key ); $key = str_replace( array( "\r\n", "\r" ), "\n", $key );

View File

@ -124,12 +124,12 @@ if ( ! class_exists( 'MO', false ) ) :
// headers' msgid is an empty string // headers' msgid is an empty string
fwrite( $fh, pack( 'VV', 0, $current_addr ) ); fwrite( $fh, pack( 'VV', 0, $current_addr ) );
$current_addr++; $current_addr++;
$originals_table = chr( 0 ); $originals_table = "\0";
$reader = new POMO_Reader(); $reader = new POMO_Reader();
foreach ( $entries as $entry ) { foreach ( $entries as $entry ) {
$originals_table .= $this->export_original( $entry ) . chr( 0 ); $originals_table .= $this->export_original( $entry ) . "\0";
$length = $reader->strlen( $this->export_original( $entry ) ); $length = $reader->strlen( $this->export_original( $entry ) );
fwrite( $fh, pack( 'VV', $length, $current_addr ) ); fwrite( $fh, pack( 'VV', $length, $current_addr ) );
$current_addr += $length + 1; // account for the NULL byte after $current_addr += $length + 1; // account for the NULL byte after
@ -138,10 +138,10 @@ if ( ! class_exists( 'MO', false ) ) :
$exported_headers = $this->export_headers(); $exported_headers = $this->export_headers();
fwrite( $fh, pack( 'VV', $reader->strlen( $exported_headers ), $current_addr ) ); fwrite( $fh, pack( 'VV', $reader->strlen( $exported_headers ), $current_addr ) );
$current_addr += strlen( $exported_headers ) + 1; $current_addr += strlen( $exported_headers ) + 1;
$translations_table = $exported_headers . chr( 0 ); $translations_table = $exported_headers . "\0";
foreach ( $entries as $entry ) { foreach ( $entries as $entry ) {
$translations_table .= $this->export_translations( $entry ) . chr( 0 ); $translations_table .= $this->export_translations( $entry ) . "\0";
$length = $reader->strlen( $this->export_translations( $entry ) ); $length = $reader->strlen( $this->export_translations( $entry ) );
fwrite( $fh, pack( 'VV', $length, $current_addr ) ); fwrite( $fh, pack( 'VV', $length, $current_addr ) );
$current_addr += $length + 1; $current_addr += $length + 1;
@ -160,10 +160,10 @@ if ( ! class_exists( 'MO', false ) ) :
//TODO: warnings for control characters //TODO: warnings for control characters
$exported = $entry->singular; $exported = $entry->singular;
if ( $entry->is_plural ) { if ( $entry->is_plural ) {
$exported .= chr( 0 ) . $entry->plural; $exported .= "\0" . $entry->plural;
} }
if ( $entry->context ) { if ( $entry->context ) {
$exported = $entry->context . chr( 4 ) . $exported; $exported = $entry->context . "\4" . $exported;
} }
return $exported; return $exported;
} }
@ -174,7 +174,7 @@ if ( ! class_exists( 'MO', false ) ) :
*/ */
function export_translations( $entry ) { function export_translations( $entry ) {
//TODO: warnings for control characters //TODO: warnings for control characters
return $entry->is_plural ? implode( chr( 0 ), $entry->translations ) : $entry->translations[0]; return $entry->is_plural ? implode( "\0", $entry->translations ) : $entry->translations[0];
} }
/** /**
@ -310,21 +310,21 @@ if ( ! class_exists( 'MO', false ) ) :
*/ */
function &make_entry( $original, $translation ) { function &make_entry( $original, $translation ) {
$entry = new Translation_Entry(); $entry = new Translation_Entry();
// look for context // Look for context, separated by \4.
$parts = explode( chr( 4 ), $original ); $parts = explode( "\4", $original );
if ( isset( $parts[1] ) ) { if ( isset( $parts[1] ) ) {
$original = $parts[1]; $original = $parts[1];
$entry->context = $parts[0]; $entry->context = $parts[0];
} }
// look for plural original // look for plural original
$parts = explode( chr( 0 ), $original ); $parts = explode( "\0", $original );
$entry->singular = $parts[0]; $entry->singular = $parts[0];
if ( isset( $parts[1] ) ) { if ( isset( $parts[1] ) ) {
$entry->is_plural = true; $entry->is_plural = true;
$entry->plural = $parts[1]; $entry->plural = $parts[1];
} }
// plural translations are also separated by \0 // plural translations are also separated by \0
$entry->translations = explode( chr( 0 ), $translation ); $entry->translations = explode( "\0", $translation );
return $entry; return $entry;
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.0-alpha-43634'; $wp_version = '5.0-alpha-43635';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.