From 88911fef8f15155f11f5eff844f1a286947a685d Mon Sep 17 00:00:00 2001 From: Pepijn Van Eeckhoudt Date: Mon, 26 Jul 2021 13:11:25 +0200 Subject: [PATCH] Resolve potential NPE in SchemaResourceResolver The LSResourceResolver interface specifies that the systemId parameter may be null. The SchemaResourceResolver uses this argument without checking for this which can result a NullPointerException. This patch adds an extra null check before using the parameter. --- ext/java/nokogiri/XmlSchema.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/java/nokogiri/XmlSchema.java b/ext/java/nokogiri/XmlSchema.java index 66cdff58d0..ff8e38fe70 100644 --- a/ext/java/nokogiri/XmlSchema.java +++ b/ext/java/nokogiri/XmlSchema.java @@ -276,7 +276,7 @@ private class SchemaResourceResolver implements LSResourceResolver String systemId, String baseURI) { - if (noNet && (systemId.startsWith("http://") || systemId.startsWith("ftp://"))) { + if (noNet && systemId != null && (systemId.startsWith("http://") || systemId.startsWith("ftp://"))) { if (systemId.startsWith(XMLConstants.W3C_XML_SCHEMA_NS_URI)) { return null; // use default resolver }