Loading tools/aapt2/ResourceParser.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -690,7 +690,9 @@ bool ResourceParser::ParseResource(xml::XmlPullParser* parser, resource_format = item_iter->second.format; } if (!ParseItem(parser, out_resource, resource_format)) { // Don't bother parsing the item if it is behind a disabled flag if (out_resource->flag_status != FlagStatus::Disabled && !ParseItem(parser, out_resource, resource_format)) { return false; } return true; Loading tools/aapt2/ResourceParser_test.cpp +20 −2 Original line number Diff line number Diff line Loading @@ -69,8 +69,13 @@ class ResourceParserTest : public ::testing::Test { return TestParse(str, ConfigDescription{}); } ::testing::AssertionResult TestParse(StringPiece str, const ConfigDescription& config) { ResourceParserOptions parserOptions; ::testing::AssertionResult TestParse(StringPiece str, ResourceParserOptions parserOptions) { return TestParse(str, ConfigDescription{}, parserOptions); } ::testing::AssertionResult TestParse( StringPiece str, const ConfigDescription& config, ResourceParserOptions parserOptions = ResourceParserOptions()) { ResourceParser parser(context_->GetDiagnostics(), &table_, android::Source{"test"}, config, parserOptions); Loading Loading @@ -242,6 +247,19 @@ TEST_F(ResourceParserTest, ParseStringTranslatableAttribute) { EXPECT_FALSE(TestParse(R"(<string name="foo4" translatable="yes">Translate</string>)")); } TEST_F(ResourceParserTest, ParseStringBehindDisabledFlag) { FeatureFlagProperties flag_properties(true, false); ResourceParserOptions options; options.feature_flag_values = {{"falseFlag", flag_properties}}; ASSERT_TRUE(TestParse( R"(<string name="foo" android:featureFlag="falseFlag" xmlns:android="http://schemas.android.com/apk/res/android">foo</string>)", options)); String* str = test::GetValue<String>(&table_, "string/foo"); ASSERT_THAT(str, IsNull()); } TEST_F(ResourceParserTest, IgnoreXliffTagsOtherThanG) { std::string input = R"( <string name="foo" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> Loading Loading
tools/aapt2/ResourceParser.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -690,7 +690,9 @@ bool ResourceParser::ParseResource(xml::XmlPullParser* parser, resource_format = item_iter->second.format; } if (!ParseItem(parser, out_resource, resource_format)) { // Don't bother parsing the item if it is behind a disabled flag if (out_resource->flag_status != FlagStatus::Disabled && !ParseItem(parser, out_resource, resource_format)) { return false; } return true; Loading
tools/aapt2/ResourceParser_test.cpp +20 −2 Original line number Diff line number Diff line Loading @@ -69,8 +69,13 @@ class ResourceParserTest : public ::testing::Test { return TestParse(str, ConfigDescription{}); } ::testing::AssertionResult TestParse(StringPiece str, const ConfigDescription& config) { ResourceParserOptions parserOptions; ::testing::AssertionResult TestParse(StringPiece str, ResourceParserOptions parserOptions) { return TestParse(str, ConfigDescription{}, parserOptions); } ::testing::AssertionResult TestParse( StringPiece str, const ConfigDescription& config, ResourceParserOptions parserOptions = ResourceParserOptions()) { ResourceParser parser(context_->GetDiagnostics(), &table_, android::Source{"test"}, config, parserOptions); Loading Loading @@ -242,6 +247,19 @@ TEST_F(ResourceParserTest, ParseStringTranslatableAttribute) { EXPECT_FALSE(TestParse(R"(<string name="foo4" translatable="yes">Translate</string>)")); } TEST_F(ResourceParserTest, ParseStringBehindDisabledFlag) { FeatureFlagProperties flag_properties(true, false); ResourceParserOptions options; options.feature_flag_values = {{"falseFlag", flag_properties}}; ASSERT_TRUE(TestParse( R"(<string name="foo" android:featureFlag="falseFlag" xmlns:android="http://schemas.android.com/apk/res/android">foo</string>)", options)); String* str = test::GetValue<String>(&table_, "string/foo"); ASSERT_THAT(str, IsNull()); } TEST_F(ResourceParserTest, IgnoreXliffTagsOtherThanG) { std::string input = R"( <string name="foo" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> Loading