Skip to content

Commit 9cc8622

Browse files
committed
Local https URL resolution attempt with fallback to parser's default
See spring-projectsgh-22504
1 parent 7cbb3b0 commit 9cc8622

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/xml/ResourceEntityResolver.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,18 @@ else if (systemId.endsWith(DTD_SUFFIX) || systemId.endsWith(XSD_SUFFIX)) {
114114
if (url.startsWith("http:")) {
115115
url = "https:" + url.substring(5);
116116
}
117-
source = new InputSource(url);
118-
source.setPublicId(publicId);
119-
return source;
117+
try {
118+
source = new InputSource(new URL(url).openStream());
119+
source.setPublicId(publicId);
120+
source.setSystemId(systemId);
121+
}
122+
catch (IOException ex) {
123+
if (logger.isDebugEnabled()) {
124+
logger.debug("Could not resolve XML entity [" + systemId + "] through URL [" + url + "]", ex);
125+
}
126+
// Fall back to the parser's default behavior.
127+
source = null;
128+
}
120129
}
121130
}
122131

0 commit comments

Comments
 (0)