jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/348751 )
Change subject: Escape newlines in AndroidXmlFFS export ...................................................................... Escape newlines in AndroidXmlFFS export Based on https://github.com/commons-app/apps-android-commons/issues/523 and testing by niedzielski this is required and the correct thing to do. Change-Id: I26343aecaadd79d20382f148b68b35235ea62027 --- M ffs/AndroidXmlFFS.php M tests/phpunit/ffs/AndroidXmlFFSTest.php 2 files changed, 6 insertions(+), 0 deletions(-) Approvals: Amire80: Looks good to me, approved Niedzielski: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/ffs/AndroidXmlFFS.php b/ffs/AndroidXmlFFS.php index 0841a61..43f572d 100644 --- a/ffs/AndroidXmlFFS.php +++ b/ffs/AndroidXmlFFS.php @@ -81,6 +81,9 @@ // All html entities seen would be inserted by translators themselves. // Treat them as plain text. $escaped = str_replace( '&', '&', $escaped ); + + // Newlines must be escaped + $escaped = str_replace( "\n", '\n', $escaped ); return $escaped; } diff --git a/tests/phpunit/ffs/AndroidXmlFFSTest.php b/tests/phpunit/ffs/AndroidXmlFFSTest.php index 8abb324..5839582 100644 --- a/tests/phpunit/ffs/AndroidXmlFFSTest.php +++ b/tests/phpunit/ffs/AndroidXmlFFSTest.php @@ -37,6 +37,7 @@ <string name="has_quotes">Go to \"Wikipedia\"</string> <string name="starts_with_at">\@Wikipedia</string> <string name="has_ampersand">1&nbsp;000</string> + <string name="has_newline">first\nsecond</string> </resources> XML; @@ -53,6 +54,7 @@ 'has_quotes' => 'Go to "Wikipedia"', 'starts_with_at' => '@Wikipedia', 'has_ampersand' => '1 000', + 'has_newline' => "first\nsecond", ]; $expected = [ 'MESSAGES' => $expected, 'AUTHORS' => [] ]; $this->assertEquals( $expected, $parsed ); @@ -70,6 +72,7 @@ 'foobar' => '!!FUZZY!!Kissa kala <koira> "a\'b', 'amuch' => '{{PLURAL|one=bunny|bunnies}}', 'ampersand' => ' &foo', + 'newlines' => "first\nsecond", ]; $collection = new MockMessageCollection( $messages ); -- To view, visit https://gerrit.wikimedia.org/r/348751 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I26343aecaadd79d20382f148b68b35235ea62027 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Nikerabbit <[email protected]> Gerrit-Reviewer: Amire80 <[email protected]> Gerrit-Reviewer: KartikMistry <[email protected]> Gerrit-Reviewer: Niedzielski <[email protected]> Gerrit-Reviewer: Nikerabbit <[email protected]> Gerrit-Reviewer: Siebrand <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
