Merge "AAPT2: Do not interpret %n as a format specifier in string resources"

This commit is contained in:
TreeHugger Robot
2017-06-06 21:39:54 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 1 deletions

View File

@@ -843,4 +843,9 @@ TEST_F(ResourceParserTest, ParseElementWithNoValue) {
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

View File

@@ -203,7 +203,7 @@ bool VerifyJavaStringFormat(const StringPiece& str) {
if (*c == '%' && c + 1 < end) {
c++;
if (*c == '%') {
if (*c == '%' || *c == 'n') {
c++;
continue;
}