Improve error message when clicking invalid link
This commit is contained in:
parent
86632804a9
commit
089131c79d
@ -33,7 +33,7 @@ from qutebrowser.config import config
|
|||||||
from qutebrowser.browser import http, tabhistory, pdfjs
|
from qutebrowser.browser import http, tabhistory, pdfjs
|
||||||
from qutebrowser.browser.network import networkmanager
|
from qutebrowser.browser.network import networkmanager
|
||||||
from qutebrowser.utils import (message, usertypes, log, jinja, qtutils, utils,
|
from qutebrowser.utils import (message, usertypes, log, jinja, qtutils, utils,
|
||||||
objreg, debug)
|
objreg, debug, urlutils)
|
||||||
|
|
||||||
|
|
||||||
class BrowserPage(QWebPage):
|
class BrowserPage(QWebPage):
|
||||||
@ -570,9 +570,8 @@ class BrowserPage(QWebPage):
|
|||||||
if typ != QWebPage.NavigationTypeLinkClicked:
|
if typ != QWebPage.NavigationTypeLinkClicked:
|
||||||
return True
|
return True
|
||||||
if not url.isValid():
|
if not url.isValid():
|
||||||
message.error(self._win_id, "Invalid link {} clicked!".format(
|
msg = urlutils.get_errstring(url, "Invalid link clicked")
|
||||||
urlstr))
|
message.error(self._win_id, msg)
|
||||||
log.webview.debug(url.errorString())
|
|
||||||
self.open_target = usertypes.ClickTarget.normal
|
self.open_target = usertypes.ClickTarget.normal
|
||||||
return False
|
return False
|
||||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||||
|
11
tests/end2end/data/invalid_link.html
Normal file
11
tests/end2end/data/invalid_link.html
Normal 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>
|
@ -113,6 +113,12 @@ Feature: Using hints
|
|||||||
And I run :follow-hint a
|
And I run :follow-hint a
|
||||||
Then the message "http://localhost:(port)/data/hello.txt" should be shown
|
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
|
### iframes
|
||||||
|
|
||||||
Scenario: Using :follow-hint inside an iframe
|
Scenario: Using :follow-hint inside an iframe
|
||||||
|
Loading…
Reference in New Issue
Block a user