dart-lang/html5lib — pull request #8 by jmesserly (2012-08-27 21:43:38+00:00)
Title: fix foreign content check, fix null in cdata, fix newline splitting

This fixes the "isForeignContent" check. It was hard to port from Python because the expression was so complicated (in the original code). This code helped me untangle it:
https://github.com/WebKit/webkit/blob/master/Source/WebCore/html/parser/HTMLTreeBuilder.cpp#L2547

Also fixes null in cdata, it should become the replacement char. The bug was in the "var nullCount = data.filter((c) => c == "\u0000").length;" line (should be using dataStr), but I went ahead and refactored/simplified the entire function (it was using two loops and lots of state variables, so it was hard to follow).

The final bug was that Dart's readAsLinesSync was splitting on "\r" as well as "\n". I'm not sure if that's a bug in readAsLinesSync, but I just changed it to do the splitting manually.

R= @sigmundch