mirror of
https://github.com/revanced/Apktool.git
synced 2024-08-28 18:16:41 +02:00
feat: de-dupe attribute names during styles writing (#3404)
This commit is contained in:
parent
03fa70bd2a
commit
247735c434
@ -24,6 +24,8 @@ import brut.util.Duo;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializable {
|
||||
@ -47,6 +49,8 @@ public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializab
|
||||
} else if (res.getResSpec().getName().indexOf('.') != -1) {
|
||||
serializer.attribute(null, "parent", "");
|
||||
}
|
||||
|
||||
Set<String> processedNames = new HashSet<>();
|
||||
for (Duo<ResReferenceValue, ResScalarValue> mItem : mItems) {
|
||||
ResResSpec spec = mItem.m1.getReferent();
|
||||
|
||||
@ -70,6 +74,11 @@ public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializab
|
||||
name = "@" + spec.getFullName(res.getResSpec().getPackage(), false);
|
||||
}
|
||||
|
||||
// #3400 - Skip duplicate values, commonly seen are duplicate key-pairs on styles.
|
||||
if (!isAnalysisMode() && processedNames.contains(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
value = mItem.m2.encodeAsResXmlValue();
|
||||
}
|
||||
@ -82,8 +91,11 @@ public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializab
|
||||
serializer.attribute(null, "name", name);
|
||||
serializer.text(value);
|
||||
serializer.endTag(null, "item");
|
||||
|
||||
processedNames.add(name);
|
||||
}
|
||||
serializer.endTag(null, "style");
|
||||
processedNames.clear();
|
||||
}
|
||||
|
||||
private final Duo<ResReferenceValue, ResScalarValue>[] mItems;
|
||||
|
@ -22,4 +22,8 @@ public class ResValue {
|
||||
public boolean shouldRemoveUnknownRes() {
|
||||
return Config.getInstance().isDecodeResolveModeRemoving();
|
||||
}
|
||||
|
||||
public boolean isAnalysisMode() {
|
||||
return Config.getInstance().analysisMode;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user