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.


git-svn-id: https://develop.svn.wordpress.org/trunk@39592 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan McCue 2016-12-13 02:47:07 +00:00
parent 32ed2a1ffa
commit bc2d2858f9

View File

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