diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 43dc54ba1..924d2bbe1 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -62,6 +62,7 @@ Fixed - When downloading files with QtWebKit, a User-Agent header is set when possible. - Fixed showing of keybindings in the :help completion - Worked around a segfault when opening a URL after a QtWebEngine renderer process crash +- Using :undo or :tab-clone with a view-source:// or chrome:// tab is now prevented, as it segfaults v0.9.1 ------ diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 0cdc92eff..4a9d9aaa3 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -427,6 +427,11 @@ class CommandDispatcher: cmdutils.check_exclusive((bg, window), 'bw') curtab = self._current_widget() cur_title = self._tabbed_browser.page_title(self._current_index()) + try: + history = curtab.history.serialize() + except browsertab.WebTabError as e: + raise cmdexc.CommandError(e) + # The new tab could be in a new tabbed_browser (e.g. because of # tabs-are-windows being set) if window: @@ -437,13 +442,15 @@ class CommandDispatcher: new_tabbed_browser = objreg.get('tabbed-browser', scope='window', window=newtab.win_id) idx = new_tabbed_browser.indexOf(newtab) + new_tabbed_browser.set_page_title(idx, cur_title) if config.get('tabs', 'show-favicons'): new_tabbed_browser.setTabIcon(idx, curtab.icon()) if config.get('tabs', 'tabs-are-windows'): new_tabbed_browser.window().setWindowIcon(curtab.icon()) + newtab.data.keep_icon = True - newtab.history.deserialize(curtab.history.serialize()) + newtab.history.deserialize(history) newtab.zoom.set_factor(curtab.zoom.factor()) return newtab diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 4c1bb9e9d..1fb01d614 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -384,6 +384,11 @@ class WebEngineHistory(browsertab.AbstractHistory): return self._history.canGoForward() def serialize(self): + # WORKAROUND for https://github.com/qutebrowser/qutebrowser/issues/2289 + # FIXME:qtwebengine can we get rid of this with Qt 5.8.1? + scheme = self._history.currentItem().url().scheme() + if scheme in ['view-source', 'chrome']: + raise browsertab.WebTabError("Can't serialize special URL!") return qtutils.serialize(self._history) def deserialize(self, data): diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 31eef4793..eba736d4a 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -268,9 +268,12 @@ class TabbedBrowser(tabwidget.TabWidget): window=self._win_id): objreg.delete('last-focused-tab', scope='window', window=self._win_id) - if tab.url().isValid(): - history_data = tab.history.serialize() - if add_undo: + if tab.url().isValid() and add_undo: + try: + history_data = tab.history.serialize() + except browsertab.WebTabError: + pass # special URL + else: entry = UndoEntry(tab.url(), history_data, idx) self._undo_stack.append(entry) elif tab.url().isEmpty(): diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 0ba6d62b7..c7f7d7d1b 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -604,6 +604,12 @@ Feature: Tab management - url: http://localhost:*/data/title.html title: Test title + # https://github.com/qutebrowser/qutebrowser/issues/2289 + Scenario: Cloning a tab with a special URL + When I open chrome://gpu + And I run :tab-clone + Then the error "Can't serialize special URL!" should be shown + # :tab-detach Scenario: Detaching a tab @@ -759,6 +765,17 @@ Feature: Tab management - data/numbers/2.txt - data/numbers/3.txt + # https://github.com/qutebrowser/qutebrowser/issues/2289 + Scenario: Undoing a tab with a special URL + Given I have a fresh instance + When I open data/numbers/1.txt + And I open chrome://gpu in a new tab + And I run :tab-close + And I run :undo + Then the error "Nothing to undo!" should be shown + And the following tabs should be open: + - data/numbers/1.txt (active) + # last-close # FIXME:qtwebengine