diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 62fb67453..14d5c0e8d 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -793,7 +793,7 @@ class AbstractTab(QWidget): def icon(self): raise NotImplementedError - def set_html(self, html, base_url): + def set_html(self, html, base_url=QUrl()): raise NotImplementedError def networkaccessmanager(self): diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index f513651cb..f70b72a32 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1375,13 +1375,8 @@ class CommandDispatcher: formatter = pygments.formatters.HtmlFormatter(full=True, linenos='table') highlighted = pygments.highlight(source, lexer, formatter) - try: - current_url = self._current_url() - except cmdexc.CommandError as e: - message.error(str(e)) - return new_tab = self._tabbed_browser.tabopen() - new_tab.set_html(highlighted, current_url) + new_tab.set_html(highlighted) new_tab.data.viewing_source = True tab.dump_async(show_source_cb) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index 294425549..d05d4b01c 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -257,6 +257,10 @@ class WebHistory(QObject): @pyqtSlot(QUrl, QUrl, str) def add_from_tab(self, url, requested_url, title): """Add a new history entry as slot, called from a BrowserTab.""" + if url.isEmpty(): + # things set via setHtml + return + no_formatting = QUrl.UrlFormattingOption(0) if (requested_url.isValid() and not requested_url.matches(url, no_formatting)): diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index af93786d6..6d6177733 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -626,14 +626,12 @@ class WebEngineTab(browsertab.AbstractTab): def icon(self): return self._widget.icon() - def set_html(self, html, base_url=None): + def set_html(self, html, base_url=QUrl()): # FIXME:qtwebengine # check this and raise an exception if too big: # Warning: The content will be percent encoded before being sent to the # renderer via IPC. This may increase its size. The maximum size of the # percent encoded content is 2 megabytes minus 30 bytes. - if base_url is None: - base_url = QUrl() self._widget.setHtml(html, base_url) def networkaccessmanager(self): diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index daf46a503..5d3d8e87a 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -710,7 +710,7 @@ class WebKitTab(browsertab.AbstractTab): requested_url = self.url(requested=True) self.add_history_item.emit(url, requested_url, self.title()) - def set_html(self, html, base_url): + def set_html(self, html, base_url=QUrl()): self._widget.setHtml(html, base_url) def networkaccessmanager(self):