NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 806 - needToDropLF flag not reset if bare LF encountered
needToDropLF flag not reset if bare LF encountered
Status: RESOLVED FIXED
Product: Validator.nu
Classification: Unclassified
Component: HTML parser
HEAD
All All
: P2 normal
Assigned To: neil
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-12-23 12:27 CET by neil
Modified: 2011-01-06 00:22 CET (History)
1 user (show)

See Also:


Attachments
Proposed patch (712 bytes, patch)
2010-12-23 12:52 CET, neil
Details

Note You need to log in before you can comment on or make changes to this bug.
Description neil 2010-12-23 12:27:32 CET
>if (needToDropLF) {
>    if (buf[start] == '\n') {
>        start++;
>        length--;
>        if (length == 0) {
>            return;
>        }
>    }
>    needToDropLF = false;
>}
If a bare LF is encountered (length == 1) then the needToDropLF flag is never reset. In this case multiple LF characters can get dropped. This is usually triggered because CR characters are is handled by emitting a bare LF and setting a flag to consume the next input character if it is an LF, but it also applies if the first LF of a PRE or TEXTAREA element is immediately followed by a CR, since that causes the buffer to be flushed.

I don't understand why emitXXX needs to flush the buffer and then handle a single character instead of appending the character to the buffer, but that's a side issue and not directly relevant to the bug.
Comment 1 neil 2010-12-23 12:52:02 CET
Created attachment 189 [details]
Proposed patch
Comment 2 Henri Sivonen 2011-01-05 15:05:11 CET
Thanks. r=hsivonen.

OK to use 'Neil Rashbrook <neil@parkwaycc.co.uk>' (as already seen on hg.mozilla.org) as the hg committer of record for landing this?
Comment 3 neil 2011-01-05 15:43:53 CET
(In reply to comment #2)
> OK to use 'Neil Rashbrook <neil@parkwaycc.co.uk>' (as already seen on
> hg.mozilla.org) as the hg committer of record for landing this?
Sure, of course.
Comment 4 Henri Sivonen 2011-01-05 17:41:24 CET
Landed. Thanks.
http://hg.mozilla.org/projects/htmlparser/rev/4e0016ea4674
Comment 5 neil 2011-01-06 00:22:57 CET
An HTML LF entity &#10; is another way to generate a bare LF.