-
-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve potential NPE in SchemaResourceResolver #2296
Conversation
Hi, @pepijnve, thanks for the PR. I'd love to be able to reproduce what you're seeing -- can you help me understand where the challenge is in finding a repro? Maybe I can help! |
The only issue is time 😄 I simply haven't tried to isolate this just yet. This issue occurred for me in https://github.com/asciidoctor/asciimath/blob/master/spec/parser_spec.rb#L10 when running the specs under JRuby. I'm loading the MathML schema (https://github.com/asciidoctor/asciimath/blob/master/spec/schema/mathml2/mathml2.xsd) from disk. The root schema file loads fine as an XML document, but when attempting to interpret it as a schema, the NPE happens when attempting to resolve the relative paths to the other schema files. |
I'm going to try loading those schemas from a standalone script to see if I can reproduce the problem and if so see if I can get the same error with a simpler schema. I'll let you know how that goes. |
results in the following stack trace
I tried the same thing with a more trivial schema, but no luck. The same code works without error with MRI. |
@pepijnve Thanks for the more detailed information! I'll take a look this weekend. |
I don't think this test ever actually ran.
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.
I've added a test that isolates this bug to the PR. Let's make sure CI goes green! |
Merging, and targetting v1.13 for this. Thanks again for your contribution! |
This has been released as part of v1.12.4. |
What problem is this PR intended to solve?
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.
Have you included adequate test coverage?
I'm seeing this NPE in my code, but I'm afraid I haven't been able to derive a simple reproduction case yet. No test yet either as a consequence.
Does this change affect the behavior of either the C or the Java implementations?
Only the Java implementation.