Skip to content

Commit 9e63639

Browse files
committed
Plug URIResolver into StaxUtils (#3293)
(cherry picked from commit 2f715e9)
1 parent fca6d19 commit 9e63639

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
import org.apache.cxf.helpers.CastUtils;
9494
import org.apache.cxf.helpers.DOMUtils;
9595
import org.apache.cxf.message.Message;
96+
import org.apache.cxf.resource.URIResolver;
9697

9798
public final class StaxUtils {
9899
// System properties for defaults, but also contextual properties usable
@@ -1693,6 +1694,7 @@ public static XMLStreamReader createXMLStreamReader(InputSource src) {
16931694
} else {
16941695
try {
16951696
final URL url = new URL(sysId);
1697+
URIResolver.checkAllowedScheme(url);
16961698
final InputStream is = url.openStream();
16971699
final StreamSource ss = new StreamSource(is, sysId);
16981700
ss.setPublicId(pubId);

core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ public void testFactoryCreation() {
7272
assertNotNull(reader);
7373
}
7474

75+
@Test
76+
public void testCreateXMLStreamReaderInputSourceHonorsAllowedSchemes() throws Exception {
77+
InputSource source = new InputSource();
78+
source.setSystemId("ftp://127.0.0.1/test.xml");
79+
80+
try {
81+
StaxUtils.createXMLStreamReader(source);
82+
fail("Failure expected on disallowed scheme");
83+
} catch (IllegalArgumentException ex) {
84+
assertEquals("InputSource must have a ByteStream or CharacterStream", ex.getMessage());
85+
}
86+
}
87+
7588
private InputStream getTestStream(String resource) {
7689
return getClass().getResourceAsStream(resource);
7790
}

0 commit comments

Comments
 (0)