fix(res): fix invalid XML NS names (PR #1158)
* Fix issue in invalid XML NS names * fix: replace methods not available in Java 8 Co-authored-by: bagipro <bugi@MacBook-Pro-2.local> Co-authored-by: Skylot <skylot@gmail.com>
This commit is contained in:
@@ -158,9 +158,10 @@ public class BinaryXMLParser extends CommonBinaryParser {
|
||||
int beginPrefix = is.readInt32();
|
||||
int beginURI = is.readInt32();
|
||||
|
||||
String nsKey = getString(beginURI);
|
||||
String nsValue = getString(beginPrefix);
|
||||
if (!nsMap.containsValue(nsValue)) {
|
||||
nsMap.putIfAbsent(getString(beginURI), nsValue);
|
||||
if (StringUtils.notBlank(nsKey) && !nsMap.containsValue(nsValue)) {
|
||||
nsMap.putIfAbsent(nsKey, nsValue);
|
||||
}
|
||||
namespaceDepth++;
|
||||
}
|
||||
@@ -178,9 +179,10 @@ public class BinaryXMLParser extends CommonBinaryParser {
|
||||
int endURI = is.readInt32();
|
||||
namespaceDepth--;
|
||||
|
||||
String nsKey = getString(endURI);
|
||||
String nsValue = getString(endPrefix);
|
||||
if (!nsMap.containsValue(nsValue)) {
|
||||
nsMap.putIfAbsent(getString(endURI), nsValue);
|
||||
if (StringUtils.notBlank(nsKey) && !nsMap.containsValue(nsValue)) {
|
||||
nsMap.putIfAbsent(nsKey, nsValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +248,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
|
||||
int styleIndex = is.readInt16();
|
||||
if ("manifest".equals(currentTag) || writer.getIndent() == 0) {
|
||||
for (Map.Entry<String, String> entry : nsMap.entrySet()) {
|
||||
String nsValue = entry.getValue();
|
||||
String nsValue = getValidTagAttributeName(entry.getValue());
|
||||
writer.add(" xmlns");
|
||||
if (nsValue != null && !nsValue.trim().isEmpty()) {
|
||||
writer.add(':');
|
||||
|
||||
Reference in New Issue
Block a user