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) @cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
def open_tab_cur(self): def open_tab_cur(self):
"""Set the statusbar to :tabopen and the current URL.""" """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) message.set_cmd_text(':open-tab ' + urlstr)
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True) @cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
def open_cur(self): def open_cur(self):
"""Set the statusbar to :open and the current URL.""" """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) message.set_cmd_text(':open ' + urlstr)
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True) @cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
def open_tab_bg_cur(self): def open_tab_bg_cur(self):
"""Set the statusbar to :tabopen-bg and the current URL.""" """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) message.set_cmd_text(':open-tab-bg ' + urlstr)
@cmdutils.register(instance='mainwindow.tabs.cmd') @cmdutils.register(instance='mainwindow.tabs.cmd')

View File

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

View File

@ -58,7 +58,7 @@ def prompt_save(url):
Args: Args:
url: The quickmark url as a QUrl. 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, message.question("Add quickmark:", PromptMode.text,
partial(quickmark_add, urlstr)) partial(quickmark_add, urlstr))

View File

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

View File

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

View File

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

View File

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