mirror of
https://github.com/appium/appium.git
synced 2026-04-25 21:08:57 -05:00
clean xml tags of invalid characters. Fixes #3305
This commit is contained in:
@@ -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", "");
|
||||
}
|
||||
}
|
||||
|
||||
+11
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user