Improve error message when clicking invalid link

This commit is contained in:
Florian Bruhin 2016-06-09 17:43:33 +02:00
parent 86632804a9
commit 089131c79d
3 changed files with 20 additions and 4 deletions

View File

@ -33,7 +33,7 @@ from qutebrowser.config import config
from qutebrowser.browser import http, tabhistory, pdfjs
from qutebrowser.browser.network import networkmanager
from qutebrowser.utils import (message, usertypes, log, jinja, qtutils, utils,
objreg, debug)
objreg, debug, urlutils)
class BrowserPage(QWebPage):
@ -570,9 +570,8 @@ class BrowserPage(QWebPage):
if typ != QWebPage.NavigationTypeLinkClicked:
return True
if not url.isValid():
message.error(self._win_id, "Invalid link {} clicked!".format(
urlstr))
log.webview.debug(url.errorString())
msg = urlutils.get_errstring(url, "Invalid link clicked")
message.error(self._win_id, msg)
self.open_target = usertypes.ClickTarget.normal
return False
tabbed_browser = objreg.get('tabbed-browser', scope='window',

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Invalid link</title>
</head>
<body>
<a href="what://::">I'm broken</a>
</body>
</html>

View File

@ -113,6 +113,12 @@ Feature: Using hints
And I run :follow-hint a
Then the message "http://localhost:(port)/data/hello.txt" should be shown
Scenario: Clicking an invalid link
When I open data/invalid_link.html
And I run :hint all
And I run :follow-hint a
Then the error "Invalid link clicked - *" should be shown
### iframes
Scenario: Using :follow-hint inside an iframe