General: Correctly detect trailing newline when prepending.

We need to check that the final line is actually an artifact of explode(), not just an empty input string.

See #37082.

Built from https://develop.svn.wordpress.org/trunk@39592


git-svn-id: http://core.svn.wordpress.org/trunk@39532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan McCue 2016-12-13 02:48:41 +00:00
parent fbc00b31ef
commit 20aa5d7150
2 changed files with 2 additions and 2 deletions

View File

@ -169,7 +169,7 @@ class PO extends Gettext_Translations {
public static function prepend_each_line($string, $with) { public static function prepend_each_line($string, $with) {
$lines = explode("\n", $string); $lines = explode("\n", $string);
$append = ''; $append = '';
if ('' === end($lines)) { if ("\n" === substr($string, -1) && '' === end($lines)) {
// Last line might be empty because $string was terminated // Last line might be empty because $string was terminated
// with a newline, remove it from the $lines array, // with a newline, remove it from the $lines array,
// we'll restore state by re-terminating the string at the end // we'll restore state by re-terminating the string at the end

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.8-alpha-39591'; $wp_version = '4.8-alpha-39592';
/** /**
* 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.