scinfu / SwiftSoup

SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)
https://scinfu.github.io/SwiftSoup/
MIT License
4.52k stars 345 forks source link

Parsing html with iframe inserts stray escaped elements into Document #253

Closed Aloisius closed 9 months ago

Aloisius commented 10 months ago

SwiftSoup appears to insert escaped nodes when parsing html that contains an iframe.

For example:

let html = "<html><body><iframe src=\"http://www.example.com\" /></body></html>"

let dirty = try! SwiftSoup.parse(html)
print(try! dirty.html())        

Will output:

<html>
 <head></head>
 <body>
  <iframe src="http://www.example.com"></iframe>&lt;/body&gt;&lt;/html&gt;
 </body>
</html>

I'd expect it to output:

<html>
 <head></head>
 <body>
  <iframe src="http://www.example.com"></iframe>
 </body>
</html>