diff --git a/autotests/locationbartest.cpp b/autotests/locationbartest.cpp index eedbe0d20..9bf1eaaad 100644 --- a/autotests/locationbartest.cpp +++ b/autotests/locationbartest.cpp @@ -128,6 +128,28 @@ void LocationBarTest::loadActionSearchTest() QCOMPARE(action.loadRequest.url(), QUrl("http://test/ttt-notsearch")); } +void LocationBarTest::loadAction_kdebug389491() +{ + // "site:website.com searchterm" is loaded instead of searched + + SearchEngine engine; + engine.name = "Test Engine"; + engine.url = "http://test/%s"; + engine.shortcut = "t"; + mApp->searchEnginesManager()->addEngine(engine); + mApp->searchEnginesManager()->setActiveEngine(engine); + + LocationBar::LoadAction action; + + action = LocationBar::loadAction("site:website.com searchterm"); + QCOMPARE(action.type, LocationBar::LoadAction::Search); + QCOMPARE(action.loadRequest.url(), QUrl("http://test/site%3Awebsite.com%20searchterm")); + + action = LocationBar::loadAction("site:website.com?search=searchterm and another"); + QCOMPARE(action.type, LocationBar::LoadAction::Url); + QCOMPARE(action.loadRequest.url(), QUrl("site:website.com?search=searchterm and another")); +} + int main(int argc, char **argv) { MainApplication::setTestModeEnabled(true); diff --git a/autotests/locationbartest.h b/autotests/locationbartest.h index eb76d8477..5c83107e4 100644 --- a/autotests/locationbartest.h +++ b/autotests/locationbartest.h @@ -31,4 +31,5 @@ private slots: void loadActionBasicTest(); void loadActionBookmarksTest(); void loadActionSearchTest(); + void loadAction_kdebug389491(); }; diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 2c29015a5..e43130002 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -263,9 +263,12 @@ LocationBar::LoadAction LocationBar::loadAction(const QString &text) // Otherwise load as url const QUrl &guessedUrl = QUrl::fromUserInput(t); if (guessedUrl.isValid()) { - action.type = LoadAction::Url; - action.loadRequest = guessedUrl; - return action; + // We only allow space in query + if (!QzTools::containsSpace(guessedUrl.toString(QUrl::RemoveQuery))) { + action.type = LoadAction::Url; + action.loadRequest = guessedUrl; + return action; + } } // Search when creating url failed