You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Malformed HTML parsed differently from browsers #512
Notice the truncated <a tag on line 4 (caused by an HTML fragment accidentally truncated in the DB).
If I create a file with this content, load it in Firefox and print the resulting DOM with document.getElementsByTagName("html")[0].outerHTML , Firefox returns:
The well-formed link with bar completely disappeared!
EDIT: See next message, there are still some differences but the ones here seem to be caused by the TreeSink impl I used, not the parser.
This difference in interpretation between Firefox/Chrome and html5ever is causing me issues when processing these documents to recover them. I'm well aware that the input is broken, but I would expect html5ever to produce the same structure as real browsers.
EDIT: Even smaller repro, removing the newline fixes the mismatch.
Activity
[-]Malformed HTML parsed differently from Firefox and Chrome[/-][+]Malformed HTML parsed differently from browsers[/+]demurgos commentedon Oct 1, 2023
Running the arena example, I actually get a result close to real browsers.
I added Debug to
html5ever/examples/arena:And then executed:
This produced a tree corresponding to:
The difference with real browsers is that:
<div>inside the second anchor, while it's empty inside browsers.Regarding the other differences, they may be caused by my
TreeSink, I'm usinghtml5everthroughscraperso I'll check there too.