diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2018-04-25 15:00:50 -0700 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2018-05-01 11:11:55 -0700 |
commit | eaf77e1d3a6ad4995ddd92a429802cffbf0f0209 (patch) | |
tree | 17a7b20a176b55367acf6655c0f77cc998b48864 /tools/aapt2/ResourceParser.cpp | |
parent | dc34eb605520a7f4f9401c4569a2573171111e9d (diff) |
AAPT2: Fixed id parsing error
A previous change, editied the logic for parsing ids to allow for ids to
reference other ids. This change though caused a regression that made
ids in the form '<id name="name" />' cease to parse. This changes fixes
that regression.
Bug: 78513618
Test: Updated tests in ResourceParser_test.cpp
Change-Id: I3608bb764464e951a50910be55e199c6ec575d09
Diffstat (limited to 'tools/aapt2/ResourceParser.cpp')
-rw-r--r-- | tools/aapt2/ResourceParser.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp index 19c6c3107e7c..7f48544c0ae4 100644 --- a/tools/aapt2/ResourceParser.cpp +++ b/tools/aapt2/ResourceParser.cpp @@ -598,10 +598,13 @@ bool ResourceParser::ParseResource(xml::XmlPullParser* parser, // If no inner element exists, represent a unique identifier out_resource->value = util::make_unique<Id>(); } else { - // If an inner element exists, the inner element must be a reference to - // another resource id Reference* ref = ValueCast<Reference>(out_resource->value.get()); - if (!ref || ref->name.value().type != ResourceType::kId) { + if (ref && !ref->name && !ref->id) { + // A null reference also means there is no inner element when ids are in the form: + // <id name="name"/> + out_resource->value = util::make_unique<Id>(); + } else if (!ref || ref->name.value().type != ResourceType::kId) { + // If an inner element exists, the inner element must be a reference to another resource id diag_->Error(DiagMessage(out_resource->source) << "<" << parser->element_name() << "> inner element must either be a resource reference or empty"); |