universal_html icon indicating copy to clipboard operation
universal_html copied to clipboard

Different behaviours in universal_html & html

Open Aulig opened this issue 3 years ago • 0 comments

It seems like universal_html does not parse iframes like html. universal_html escapes the content of the iframes, while html doesn't.

Code to reproduce the issue:

import 'package:html/parser.dart';
import 'package:universal_html/parsing.dart';

main() async {

  String html = """ 
<!DOCTYPE HTML>
<html>
<head></head>
<body>
  <iframe>
  <!DOCTYPE html>
  <html>
  <head></head>
  <body>
    <p id="test-id">Test</p>
  </body>
  </html>
  </iframe>
</body>
</html>
  """;

  print(parseHtmlDocument(html).querySelector("iframe")!.innerHtml);
  print(parse(html).querySelector("iframe")!.innerHtml);
}

Output:

  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;p id="test-id"&gt;Test&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  

  <!DOCTYPE html>
  <html>
  <head></head>
  <body>
    <p id="test-id">Test</p>
  </body>
  </html>

Aulig avatar Jun 01 '21 13:06 Aulig