Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.resource.URIResolver;

public final class StaxUtils {
// System properties for defaults, but also contextual properties usable
Expand Down Expand Up @@ -1693,6 +1694,7 @@ public static XMLStreamReader createXMLStreamReader(InputSource src) {
} else {
try {
final URL url = new URL(sysId);
URIResolver.checkAllowedScheme(url);
final InputStream is = url.openStream();
final StreamSource ss = new StreamSource(is, sysId);
ss.setPublicId(pubId);
Expand Down
13 changes: 13 additions & 0 deletions core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ public void testFactoryCreation() {
assertNotNull(reader);
}

@Test
public void testCreateXMLStreamReaderInputSourceHonorsAllowedSchemes() throws Exception {
InputSource source = new InputSource();
source.setSystemId("ftp://127.0.0.1/test.xml");

try {
StaxUtils.createXMLStreamReader(source);
fail("Failure expected on disallowed scheme");
} catch (IllegalArgumentException ex) {
assertEquals("InputSource must have a ByteStream or CharacterStream", ex.getMessage());
}
}

private InputStream getTestStream(String resource) {
return getClass().getResourceAsStream(resource);
}
Expand Down
Loading