Local https URL resolution attempt with fallback to parser's default

See gh-22504
This commit is contained in:
Juergen Hoeller
2019-03-06 16:23:45 +01:00
parent 7cbb3b06a0
commit 9cc862246f

View File

@@ -114,9 +114,18 @@ public class ResourceEntityResolver extends DelegatingEntityResolver {
if (url.startsWith("http:")) {
url = "https:" + url.substring(5);
}
source = new InputSource(url);
source.setPublicId(publicId);
return source;
try {
source = new InputSource(new URL(url).openStream());
source.setPublicId(publicId);
source.setSystemId(systemId);
}
catch (IOException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Could not resolve XML entity [" + systemId + "] through URL [" + url + "]", ex);
}
// Fall back to the parser's default behavior.
source = null;
}
}
}