未验证 提交 5d7f2c70 编写于 作者: S skylot 提交者: GitHub

Merge pull request #301 from skylot/public_xml_no_dups

Prevent adding duplicate ids for resource entries with different entry configs
......@@ -3,7 +3,9 @@ package jadx.core.xmlgen;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -89,10 +91,13 @@ public class ResTableParser extends CommonBinaryParser {
writer.startLine("<resources>");
writer.incIndent();
Set<String> addedValues = new HashSet<>();
for (ResourceEntry ri : resStorage.getResources()) {
String format = String.format("<public type=\"%s\" name=\"%s\" id=\"%s\" />",
ri.getTypeName(), ri.getKeyName(), ri.getId());
writer.startLine(format);
if(addedValues.add(ri.getTypeName() + "." + ri.getKeyName())) {
String format = String.format("<public type=\"%s\" name=\"%s\" id=\"%s\" />",
ri.getTypeName(), ri.getKeyName(), ri.getId());
writer.startLine(format);
}
}
writer.decIndent();
writer.startLine("</resources>");
......
......@@ -205,6 +205,9 @@ public class JResource extends JLoadableNode implements Comparable<JResource> {
if (ext.equals("html")) {
return SyntaxConstants.SYNTAX_STYLE_HTML;
}
if(ext.equals("arsc")) {
return SyntaxConstants.SYNTAX_STYLE_XML;
}
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册