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:
parent
32ed2a1ffa
commit
bc2d2858f9
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user