gildas-lormeau / SingleFileZ

Web Extension to save a faithful copy of an entire web page in a self-extracting ZIP file
GNU Affero General Public License v3.0
1.82k stars 140 forks source link

Check that document.doctype is not null #127

Closed nettybun closed 2 years ago

nettybun commented 2 years ago

I ran into this because I wanted an export of a Google Doc without page breaks. PDF needs page breaks, so I thought SingleFile would be good. The SingleFIleZ extension ran fine without error but the resulting HTML file showed only a blank page with this error:

Screen Shot 2022-04-29 at 6 42 23 PM

The red underline is wrong - it's actually the .remove() which throws the error. https://developer.mozilla.org/en-US/docs/Web/API/Document/doctype#notes says it can be null.

I opened the Google Doc HTML export and saw it was missing a doctype:

image

Adding <!DOCTYPE html> and rerunning SingleFileZ on the patched file fixed it. It'd been good is SingleFileZ could handle these broken HTML files though.

I'm in Firefox 99 so maybe this doesn't happen in Chrome.

nettybun commented 2 years ago

Also it looks like SingleFile (not Z) is also doing this: https://github.com/gildas-lormeau/SingleFile/search?q=doctype.remove%28%29

gildas-lormeau commented 2 years ago

Thank you, I agree that it's a bug that should be fixed.