From 626bf8f4bbe885463e247010585f61649d96206d Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 16 Apr 2015 17:28:04 +0200 Subject: [PATCH] Fix searching for strings with special whitespaces from locationbar This fixes eg. search terms with double byte space. Closes #1622 --- src/lib/tools/qztools.cpp | 9 +++++++++ src/lib/tools/qztools.h | 2 ++ src/lib/webengine/webview.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp index 70ce591cf..3fbfb8fce 100644 --- a/src/lib/tools/qztools.cpp +++ b/src/lib/tools/qztools.cpp @@ -557,6 +557,15 @@ bool QzTools::isUtf8(const char* string) return true; } +bool QzTools::containsSpace(const QString &str) +{ + Q_FOREACH (const QChar &c, str) { + if (c.isSpace()) + return true; + } + return false; +} + QString QzTools::getExistingDirectory(const QString &name, QWidget* parent, const QString &caption, const QString &dir, QFileDialog::Options options) { Settings settings; diff --git a/src/lib/tools/qztools.h b/src/lib/tools/qztools.h index d99c2eabc..199df5c36 100644 --- a/src/lib/tools/qztools.h +++ b/src/lib/tools/qztools.h @@ -72,6 +72,8 @@ public: static QIcon iconFromFileName(const QString &fileName); static bool isUtf8(const char* string); + static bool containsSpace(const QString &str); + // QFileDialog static functions that remembers last used directory static QString getExistingDirectory(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), QFileDialog::Options options = QFileDialog::ShowDirsOnly); static QString getOpenFileName(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString* selectedFilter = 0, QFileDialog::Options options = 0); diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 3e3b1f28c..30be71abf 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -173,7 +173,7 @@ void WebView::load(const LoadRequest &request) // Make sure to correctly load hosts like localhost (eg. without the dot) if (!reqUrl.isEmpty() && reqUrl.scheme().isEmpty() && - !reqUrl.path().contains(QL1C(' ')) && + !QzTools::containsSpace(reqUrl.path()) && // See #1622 !reqUrl.path().contains(QL1C('.')) ) { QUrl u(QSL("http://") + reqUrl.path());