diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp index 5352ca8679b3e..c6382b177f420 100644 --- a/tools/aapt2/ResourceParser_test.cpp +++ b/tools/aapt2/ResourceParser_test.cpp @@ -843,4 +843,9 @@ TEST_F(ResourceParserTest, ParseElementWithNoValue) { EXPECT_THAT(*str->value, Eq("")); } +TEST_F(ResourceParserTest, ParsePlatformIndependentNewline) { + std::string input = R"(%1$s %n %2$s)"; + ASSERT_TRUE(TestParse(input)); +} + } // namespace aapt diff --git a/tools/aapt2/util/Util.cpp b/tools/aapt2/util/Util.cpp index cf2232254ec40..28e952e25a67d 100644 --- a/tools/aapt2/util/Util.cpp +++ b/tools/aapt2/util/Util.cpp @@ -203,7 +203,7 @@ bool VerifyJavaStringFormat(const StringPiece& str) { if (*c == '%' && c + 1 < end) { c++; - if (*c == '%') { + if (*c == '%' || *c == 'n') { c++; continue; }