clean xml tags of invalid characters. Fixes #3305

This commit is contained in:
Jonah Stiennon
2014-08-19 16:47:08 -07:00
parent 4f3a7eba76
commit 139667d984
2 changed files with 22 additions and 0 deletions
@@ -145,6 +145,10 @@ public abstract class XMLHierarchy {
}
}
// set the node's tag name to the same as it's android class.
// also number all instances of each class with an "instance" number. It increments for each class separately.
// this allows use to use class and instance to identify a node.
// we also take this chance to clean class names that might have dollar signs in them (and other odd characters)
private static void visitNode(Node node, HashMap<String, Integer> instances) {
Document doc = node.getOwnerDocument();
@@ -157,6 +161,8 @@ public abstract class XMLHierarchy {
return;
}
androidClass = cleanTagName(androidClass);
if (!instances.containsKey(androidClass)) {
instances.put(androidClass, 0);
}
@@ -170,4 +176,9 @@ public abstract class XMLHierarchy {
instances.put(androidClass, instance+1);
}
private static String cleanTagName(String name) {
name = name.replaceAll("[$@#&]", ".");
return name.replaceAll("\\s", "");
}
}
File diff suppressed because one or more lines are too long