From bc2d2858f9d83f4194581ece9ee975b453ad2e74 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Tue, 13 Dec 2016 02:47:07 +0000 Subject: [PATCH] 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 --- src/wp-includes/pomo/po.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php index 1fc8a469d2..c31c7627df 100644 --- a/src/wp-includes/pomo/po.php +++ b/src/wp-includes/pomo/po.php @@ -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