validator / htmlparser

The Validator.nu HTML parser https://about.validator.nu/htmlparser/
Other
56 stars 26 forks source link

Prevent NPE in HtmlAttributes.getIndex #91

Open sideshowbarker opened 7 months ago

sideshowbarker commented 7 months ago

Apparently it’s possible for a mode value to be such that AttributeName.getQName(mode) returns null. So this change adds a null check to catch that.

Otherwise, without this change, some documents cause that code to throw a NullPointerException.

The NullPointerException is reproducible by parsing the document at https://usbliss.com/?attachment_id=2232 — or by giving that document to the https://validator.w3.org/nu/ checker to check:

https://validator.w3.org/nu/?doc=https://usbliss.com/?attachment_id=2232

That causes the checker to emit the following message:

Internal Error: Oops. That was not supposed to happen. A bug manifested itself in the application internals. Unable to continue. Sorry. The admin was notified.

(The admin who gets notified is me, and notification I get is a stack trace pointing to the NPE inHtmlAttributes.getIndex.)

hsivonen commented 7 months ago

That's really weird. I guess I will need to see in a debugger what's going on.