Prevent loading from resource pool if type is not a resolveable resource (#3187)

* perf: prefer the shifted resId vs expensive package calls

* fix: only lookup values if reference/value
This commit is contained in:
Connor Tumbleson 2023-07-20 21:32:19 -04:00 committed by GitHub
parent 261003316e
commit d4ec44de41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -387,7 +387,14 @@ public class AXmlResourceParser implements XmlResourceParser {
if (mAttrDecoder != null) {
try {
String stringBlockValue = valueRaw == -1 ? null : ResXmlEncoders.escapeXmlChars(mStringBlock.getString(valueRaw));
String resourceMapValue = mAttrDecoder.decodeFromResourceId(valueData);
String resourceMapValue = null;
// Ensure we only track down obfuscated values for reference/attribute type values. Otherwise we might
// spam lookups against resource table for invalid ids.
if (valueType == TypedValue.TYPE_REFERENCE || valueType == TypedValue.TYPE_DYNAMIC_REFERENCE ||
valueType == TypedValue.TYPE_ATTRIBUTE || valueType == TypedValue.TYPE_DYNAMIC_ATTRIBUTE) {
resourceMapValue = mAttrDecoder.decodeFromResourceId(valueData);
}
String value = stringBlockValue;
if (stringBlockValue != null && resourceMapValue != null) {

View File

@ -46,10 +46,8 @@ public class ResAttrDecoder {
throws AndrolibException {
if (attrResId != 0) {
ResID resId = new ResID(attrResId);
try {
ResResSpec resResSpec = mResTable.getResSpec(resId);
ResResSpec resResSpec = mResTable.getResSpec(attrResId);
if (resResSpec != null) {
return resResSpec.getName();
}