diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 407718386..a8fe9f8a9 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -387,7 +387,7 @@ class Application(QApplication): log.init.debug("Opening startpage") for urlstr in config.get('general', 'startpage'): try: - url = urlutils.fuzzy_url(urlstr) + url = urlutils.fuzzy_url(urlstr, do_search=False) except urlutils.FuzzyUrlError as e: message.error(0, "Error when opening startpage: " "{}".format(e)) diff --git a/qutebrowser/browser/quickmarks.py b/qutebrowser/browser/quickmarks.py index 9224baa5c..17f352df3 100644 --- a/qutebrowser/browser/quickmarks.py +++ b/qutebrowser/browser/quickmarks.py @@ -137,7 +137,7 @@ class QuickmarkManager(QObject): "Quickmark '{}' does not exist!".format(name)) urlstr = self.marks[name] try: - url = urlutils.fuzzy_url(urlstr) + url = urlutils.fuzzy_url(urlstr, do_search=False) except urlutils.FuzzyUrlError: raise cmdexc.CommandError( "Invalid URL for quickmark {}: {} ({})".format( diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py index 5acc97eaa..d3ddd0d2b 100644 --- a/qutebrowser/utils/urlutils.py +++ b/qutebrowser/utils/urlutils.py @@ -138,13 +138,14 @@ def _is_url_dns(url): return not info.error() -def fuzzy_url(urlstr, cwd=None, relative=False): +def fuzzy_url(urlstr, cwd=None, relative=False, do_search=True): """Get a QUrl based on an user input which is URL or search term. Args: urlstr: URL to load as a string. cwd: The current working directory, or None. relative: Whether to resolve relative files. + do_search: Whether to perform a search on non-URLs. Return: A target QUrl to a searchpage or the original URL. @@ -166,7 +167,7 @@ def fuzzy_url(urlstr, cwd=None, relative=False): if path is not None and os.path.exists(path): log.url.debug("URL is a local file") url = QUrl.fromLocalFile(path) - elif is_url(stripped): + elif (not do_search) or is_url(stripped): # probably an address log.url.debug("URL is a fuzzy address") url = qurl_from_user_input(urlstr) @@ -178,7 +179,7 @@ def fuzzy_url(urlstr, cwd=None, relative=False): url = qurl_from_user_input(stripped) log.url.debug("Converting fuzzy term {} to URL -> {}".format( urlstr, url.toDisplayString())) - if config.get('general', 'auto-search'): + if do_search and config.get('general', 'auto-search'): qtutils.ensure_valid(url) else: if not url.isValid():