Introduce a binary-safe wrapper for strlen() and use it in seems_utf8(), utf8_uri_encode(), and wp_read_image_metadata().

Use binary-safe POMO_Reader::strlen() in MO::export_to_file_handle().

fixes #28162.
Built from https://develop.svn.wordpress.org/trunk@28806


git-svn-id: http://core.svn.wordpress.org/trunk@28615 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2014-06-23 14:48:14 +00:00
parent 2b8460af62
commit 9ceb642b2a
4 changed files with 27 additions and 7 deletions

View File

@@ -75,21 +75,23 @@ class MO extends Gettext_Translations {
$current_addr++;
$originals_table = chr(0);
$reader = new POMO_Reader();
foreach($entries as $entry) {
$originals_table .= $this->export_original($entry) . chr(0);
$length = strlen($this->export_original($entry));
$length = $reader->strlen($this->export_original($entry));
fwrite($fh, pack('VV', $length, $current_addr));
$current_addr += $length + 1; // account for the NULL byte after
}
$exported_headers = $this->export_headers();
fwrite($fh, pack('VV', strlen($exported_headers), $current_addr));
fwrite($fh, pack('VV', $reader->strlen($exported_headers), $current_addr));
$current_addr += strlen($exported_headers) + 1;
$translations_table = $exported_headers . chr(0);
foreach($entries as $entry) {
$translations_table .= $this->export_translations($entry) . chr(0);
$length = strlen($this->export_translations($entry));
$length = $reader->strlen($this->export_translations($entry));
fwrite($fh, pack('VV', $length, $current_addr));
$current_addr += $length + 1;
}