AAPT2: Do not interpret %n as a format specifier in string resources
%n is a special value marking a platform independent newline and is
not to be considered a format argument.
Bug: 37132275
Test: make aapt2_tests
Change-Id: I806521e44afe20004344dee9f18ecee6cc7086ea
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp
index 5352ca8..c6382b1 100644
--- a/tools/aapt2/ResourceParser_test.cpp
+++ b/tools/aapt2/ResourceParser_test.cpp
@@ -843,4 +843,9 @@
EXPECT_THAT(*str->value, Eq(""));
}
+TEST_F(ResourceParserTest, ParsePlatformIndependentNewline) {
+ std::string input = R"(<string name="foo">%1$s %n %2$s</string>)";
+ ASSERT_TRUE(TestParse(input));
+}
+
} // namespace aapt