WebMemex / freeze-dry

Snapshots a web page to get it as a static, self-contained HTML document.
https://freezedry.webmemex.org
The Unlicense
270 stars 18 forks source link

Inlining corrupt stylesheets can corrupt html #17

Closed Treora closed 6 years ago

Treora commented 6 years ago

We currently turn a <link rel="stylesheet" href="..."> into a <style> element with the resolved contents of that URL. If resolving results in a 404 html page for example, its content will be inserted into the document and mess it up completely. Things to look at and consider changing:

  1. Sanitise the content; set innerText rather than setting innerHTML?
  2. Put the stylesheet contents as a data URL in the link's href, instead of creating a <style> element; this was the initial approach but it was changed because of a performance problem in Firefox (could that be fixed in Firefox?).
  3. Try send the proper Accept headers when fetching the stylesheet.
Treora commented 6 years ago

Option 2 has been implemented in commit da6fc31, should solve this problem.

Independently, option 3 may still be good to pursue some day.