Skip to content

Commit

Permalink
Merged revisions 948131 via svnmerge from
Browse files Browse the repository at this point in the history
https://svn.apache.org/repos/asf/cxf/trunk

........
  r948131 | dkulp | 2010-05-25 13:52:01 -0400 (Tue, 25 May 2010) | 1 line
  
  Turn off DTD and Entity expansion stuff in the XMLStreamReaders
........


git-svn-id: https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes@948162 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed May 25, 2010
1 parent f991289 commit 63a0a67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import javax.xml.stream.StreamFilter;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLResolver;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
Expand Down Expand Up @@ -136,8 +137,7 @@ public static boolean isWoodstox() {
private static XMLInputFactory getXMLInputFactory() {
XMLInputFactory f = NS_AWARE_INPUT_FACTORY_POOL.poll();
if (f == null) {
f = XMLInputFactory.newInstance();
f.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
f = createXMLInputFactory(true);
}
return f;
}
Expand Down Expand Up @@ -166,6 +166,16 @@ private static void returnXMLOutputFactory(XMLOutputFactory factory) {
public static XMLInputFactory createXMLInputFactory(boolean nsAware) {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, nsAware);
factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
factory.setXMLResolver(new XMLResolver() {
public Object resolveEntity(String publicID, String systemID,
String baseURI, String namespace)
throws XMLStreamException {
throw new XMLStreamException("Reading external entities is disabled");
}
});
return factory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import java.io.IOException;
import java.io.InputStream;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;

import org.apache.cxf.staxutils.StaxUtils;
import org.apache.xmlbeans.XmlObject;

/**
Expand Down Expand Up @@ -61,7 +61,7 @@ public void serialize(XmlObject xObj, XMLStreamWriter writer) throws IOException
xObj.save(tmpFile);

InputStream tmpIn = new FileInputStream(tmpFile);
XMLStreamReader rdr = XMLInputFactory.newInstance().createXMLStreamReader(tmpIn);
XMLStreamReader rdr = StaxUtils.createXMLStreamReader(tmpIn);

while (rdr.hasNext()) {

Expand Down

0 comments on commit 63a0a67

Please sign in to comment.