Make sure we don't display passwords in URLs to the user

This commit is contained in:
Florian Bruhin 2014-06-20 19:50:44 +02:00
parent d3196fe683
commit 8b6af23b13
7 changed files with 12 additions and 11 deletions

View File

@ -449,19 +449,19 @@ class CommandDispatcher:
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
def open_tab_cur(self):
"""Set the statusbar to :tabopen and the current URL."""
urlstr = self._tabs.currentWidget().url().toString()
urlstr = self._tabs.currentWidget().url().toDisplayString()
message.set_cmd_text(':open-tab ' + urlstr)
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
def open_cur(self):
"""Set the statusbar to :open and the current URL."""
urlstr = self._tabs.currentWidget().url().toString()
urlstr = self._tabs.currentWidget().url().toDisplayString()
message.set_cmd_text(':open ' + urlstr)
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
def open_tab_bg_cur(self):
"""Set the statusbar to :tabopen-bg and the current URL."""
urlstr = self._tabs.currentWidget().url().toString()
urlstr = self._tabs.currentWidget().url().toDisplayString()
message.set_cmd_text(':open-tab-bg ' + urlstr)
@cmdutils.register(instance='mainwindow.tabs.cmd')

View File

@ -318,7 +318,7 @@ class HintManager(QObject):
Target.cmd_tab_bg: 'open-tab-bg',
}
message.set_cmd_text(':{} {}'.format(commands[self._context.target],
url.toString(QUrl.FullyEncoded)))
url.toDisplayString()))
def _download(self, url):
"""Download a hint URL.

View File

@ -58,7 +58,7 @@ def prompt_save(url):
Args:
url: The quickmark url as a QUrl.
"""
urlstr = url.toString(QUrl.FullyEncoded)
urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded)
message.question("Add quickmark:", PromptMode.text,
partial(quickmark_add, urlstr))

View File

@ -103,7 +103,7 @@ class BrowserPage(QWebPage):
info = sip.cast(opt, QWebPage.ErrorPageExtensionOption)
errpage = sip.cast(out, QWebPage.ErrorPageExtensionReturn)
errpage.baseUrl = info.url
urlstr = info.url.toString()
urlstr = info.url.toDisplayString()
if (info.domain, info.error) in ignored_errors:
log.webview.debug("Ignored error on {}: {} (error domain: {}, "
"error code: {})".format(

View File

@ -82,8 +82,8 @@ class QuteSchemeHandler(SchemeHandler):
"""
path = request.url().path()
# An url like "qute:foo" is split as "scheme:path", not "scheme:host".
log.misc.debug("url: {}, path: {}".format(request.url().toString(),
path))
log.misc.debug("url: {}, path: {}".format(
request.url().toDisplayString(), path))
try:
handler = getattr(QuteHandlers, path)
except AttributeError:

View File

@ -126,7 +126,7 @@ def fuzzy_url(urlstr):
except ValueError: # invalid search engine
url = QUrl.fromUserInput(urlstr)
logger.debug("Converting fuzzy term {} to URL -> {}".format(
urlstr, url.toString()))
urlstr, url.toDisplayString()))
return url

View File

@ -121,7 +121,8 @@ class WebView(QWebView):
# FIXME find some way to hide scrollbars without setScrollBarPolicy
def __repr__(self):
return "WebView(url='{}')".format(elide(self.url().toString(), 50))
url = self.url().toDisplayString()
return "WebView(url='{}')".format(elide(url, 50))
@property
def load_status(self):
@ -292,7 +293,7 @@ class WebView(QWebView):
Emit:
titleChanged
"""
urlstr = url.toString()
urlstr = url.toDisplayString()
log.webview.debug("New title: {}".format(urlstr))
self.titleChanged.emit(urlstr)
self.url_text = urlstr