diff --git a/autotests/locationbartest.cpp b/autotests/locationbartest.cpp index 14e746565..68303fb36 100644 --- a/autotests/locationbartest.cpp +++ b/autotests/locationbartest.cpp @@ -214,4 +214,17 @@ void LocationBarTest::loadAction_issue2578() QCOMPARE(action.type, LocationBar::LoadAction::Invalid); } +void LocationBarTest::loadAction_kdebug392445() +{ + // %20 in url will make it incorrectly treat as web search + + qzSettings->searchFromAddressBar = true; + + LocationBar::LoadAction action; + + action = LocationBar::loadAction("http://www.example.com/my%20beautiful%20page"); + QCOMPARE(action.type, LocationBar::LoadAction::Url); + QCOMPARE(action.loadRequest.url(), QUrl("http://www.example.com/my%20beautiful%20page")); +} + FALKONTEST_MAIN(LocationBarTest) diff --git a/autotests/locationbartest.h b/autotests/locationbartest.h index 29cc6e845..ed3f8ad55 100644 --- a/autotests/locationbartest.h +++ b/autotests/locationbartest.h @@ -34,4 +34,5 @@ private Q_SLOTS: void loadAction_kdebug389491(); void loadActionSpecialSchemesTest(); void loadAction_issue2578(); + void loadAction_kdebug392445(); }; diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 29002dcd9..749900a5a 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -277,12 +277,12 @@ LocationBar::LoadAction LocationBar::loadAction(const QString &text) } // Otherwise load as url - const QUrl &guessedUrl = QUrl::fromUserInput(t); + const QUrl guessedUrl = QUrl::fromUserInput(t); if (guessedUrl.isValid()) { // Always allow javascript: to be loaded const bool forceLoad = guessedUrl.scheme() == QL1S("javascript"); // Only allow spaces in query - if (forceLoad || !QzTools::containsSpace(guessedUrl.toString(QUrl::RemoveQuery))) { + if (forceLoad || !QzTools::containsSpace(t) || !QzTools::containsSpace(guessedUrl.toString(QUrl::RemoveQuery))) { // Only allow whitelisted schemes static const QSet whitelistedSchemes = { QSL("http"), QSL("https"), QSL("ftp"), QSL("file"),