NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 823 - Array index out of bounds in meta scanner
Array index out of bounds in meta scanner
Status: RESOLVED FIXED
Product: Validator.nu
Classification: Unclassified
Component: HTML parser
HEAD
All All
: P2 normal
Assigned To: Nobody
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-08 20:52 CEST by Enrico Scoda
Modified: 2011-05-16 19:14 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enrico Scoda 2011-04-08 20:52:53 CEST
The following code:
<meta property=og:site_name content=eFlorist Mobile - TT />

is generating the following stacktrace:
java.lang.ArrayIndexOutOfBoundsException: -1
	at nu.validator.htmlparser.impl.MetaScanner.stateLoop(MetaScanner.java:398)
	at nu.validator.htmlparser.io.MetaSniffer.sniff(MetaSniffer.java:97)
        ...

I simply fixed the code by checking that contentIndex, charsetIndex and httpEquivIndex are equal or greater than 0.
Sorry, unable to give you a patch. These are the edited lines (starting 398 of MetaScanner.java):

Line 398:
if (contentIndex >= 0 && contentIndex < CONTENT.length && c == CONTENT[contentIndex]) {

Line 403:
if (charsetIndex >= 0 && charsetIndex < CHARSET.length && c == CHARSET[charsetIndex]) {

Line 408:
if (httpEquivIndex >= 0 && httpEquivIndex < HTTP_EQUIV.length && c == HTTP_EQUIV[httpEquivIndex]) {
Comment 1 Henri Sivonen 2011-05-16 19:14:49 CEST
Good catch! Fixed http://hg.mozilla.org/projects/htmlparser/rev/a2b48a25f665