From 252dc9a8bd747c3d1f5b997dd3fb5896cdf68cbd Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 24 Oct 2015 11:32:25 +0200 Subject: [PATCH] mhtml: Don't attempt to download hostblocked urls --- qutebrowser/browser/mhtml.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qutebrowser/browser/mhtml.py b/qutebrowser/browser/mhtml.py index 23170f621..d6c5de8a1 100644 --- a/qutebrowser/browser/mhtml.py +++ b/qutebrowser/browser/mhtml.py @@ -297,6 +297,15 @@ class _Downloader(): log.downloads.debug("loading asset at %s", url) + host_blocker = objreg.get('host-blocker') + if host_blocker.is_blocked(url): + log.downloads.debug("Skipping %s, host-blocked", url) + # We still need an empty file in the output, QWebView can be pretty + # picky about displaying a file correctly when not all assets are + # at least referenced in the mhtml file. + self.writer.add_file(urlutils.encoded_url(url), b'') + return + download_manager = objreg.get('download-manager', scope='window', window='current') item = download_manager.get(url, fileobj=_NoCloseBytesIO(), @@ -374,6 +383,7 @@ class _Downloader(): log.downloads.debug("Oops! Download already gone: %s", item) return item.fileobj.actual_close() + # Add a stub file, see comment in .fetch_url() for more information self.writer.add_file(urlutils.encoded_url(url), b'') if self.pending_downloads: return