7195301: XML Signature DOM implementation should not use instanceof to determine type of Node
Reviewed-by: xuelei
This commit is contained in:
parent
e0782017fe
commit
21f5431109
@ -153,8 +153,8 @@ public final class Init {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
|
||||
if (!(el instanceof Element)) {
|
||||
for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
|
||||
if (el.getNodeType() != Node.ELEMENT_NODE) {
|
||||
continue;
|
||||
}
|
||||
String tag=el.getLocalName();
|
||||
|
@ -205,7 +205,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
try {
|
||||
NameSpaceSymbTable ns=new NameSpaceSymbTable();
|
||||
int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
|
||||
if (rootNode instanceof Element) {
|
||||
if (rootNode != null && rootNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
//Fills the nssymbtable with the definitions of the parent of the root subnode
|
||||
getParentNameSpaces((Element)rootNode,ns);
|
||||
nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
|
||||
@ -335,7 +335,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
return;
|
||||
sibling=parentNode.getNextSibling();
|
||||
parentNode=parentNode.getParentNode();
|
||||
if (!(parentNode instanceof Element)) {
|
||||
if (parentNode !=null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
|
||||
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
|
||||
parentNode=null;
|
||||
}
|
||||
@ -391,7 +391,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
return;
|
||||
boolean currentNodeIsVisible = false;
|
||||
NameSpaceSymbTable ns=new NameSpaceSymbTable();
|
||||
if (currentNode instanceof Element)
|
||||
if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE)
|
||||
getParentNameSpaces((Element)currentNode,ns);
|
||||
Node sibling=null;
|
||||
Node parentNode=null;
|
||||
@ -512,7 +512,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
return;
|
||||
sibling=parentNode.getNextSibling();
|
||||
parentNode=parentNode.getParentNode();
|
||||
if (!(parentNode instanceof Element)) {
|
||||
if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
|
||||
parentNode=null;
|
||||
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
|
||||
}
|
||||
@ -594,18 +594,14 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) {
|
||||
List<Element> parents=new ArrayList<Element>(10);
|
||||
Node n1=el.getParentNode();
|
||||
if (!(n1 instanceof Element)) {
|
||||
if (n1 == null || n1.getNodeType() != Node.ELEMENT_NODE) {
|
||||
return;
|
||||
}
|
||||
//Obtain all the parents of the elemnt
|
||||
Element parent=(Element) n1;
|
||||
while (parent!=null) {
|
||||
parents.add(parent);
|
||||
Node n=parent.getParentNode();
|
||||
if (!(n instanceof Element )) {
|
||||
break;
|
||||
}
|
||||
parent=(Element)n;
|
||||
Node parent = n1;
|
||||
while (parent!=null && parent.getNodeType() == Node.ELEMENT_NODE) {
|
||||
parents.add((Element)parent);
|
||||
parent = parent.getParentNode();
|
||||
}
|
||||
//Visit them in reverse order.
|
||||
ListIterator<Element> it=parents.listIterator(parents.size());
|
||||
|
@ -1445,7 +1445,7 @@ public class XMLCipher {
|
||||
// The de-serialiser returns a fragment whose children we need to
|
||||
// take on.
|
||||
|
||||
if (sourceParent instanceof Document) {
|
||||
if (sourceParent != null && sourceParent.getNodeType() == Node.DOCUMENT_NODE) {
|
||||
|
||||
// If this is a content decryption, this may have problems
|
||||
|
||||
|
@ -283,7 +283,7 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
|
||||
Element e=null;
|
||||
while (it.hasNext()) {
|
||||
Node currentNode=it.next();
|
||||
if (currentNode instanceof Element) {
|
||||
if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
e=(Element)currentNode;
|
||||
break;
|
||||
}
|
||||
@ -292,14 +292,14 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
|
||||
List<Element> parents=new ArrayList<Element>(10);
|
||||
|
||||
//Obtain all the parents of the elemnt
|
||||
do {
|
||||
while (e != null) {
|
||||
parents.add(e);
|
||||
Node n=e.getParentNode();
|
||||
if (!(n instanceof Element )) {
|
||||
if (n == null || n.getNodeType() != Node.ELEMENT_NODE) {
|
||||
break;
|
||||
}
|
||||
e=(Element)n;
|
||||
} while (e!=null);
|
||||
}
|
||||
//Visit them in reverse order.
|
||||
ListIterator<Element> it2=parents.listIterator(parents.size()-1);
|
||||
Element ele=null;
|
||||
|
@ -225,7 +225,7 @@ public class IdResolver {
|
||||
} while (sibling==null && parentNode!=null) {
|
||||
sibling=parentNode.getNextSibling();
|
||||
parentNode=parentNode.getParentNode();
|
||||
if (!(parentNode instanceof Element)) {
|
||||
if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
|
||||
parentNode=null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user