Merge pull request #301 from skylot/public_xml_no_dups

Prevent adding duplicate ids for resource entries with different entry configs
This commit is contained in:
skylot
2018-06-27 20:46:28 +03:00
committed by GitHub
2 changed files with 11 additions and 3 deletions
@@ -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;
}