mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
LocationBar: Only allow spaces in url query
Fixes correctly searching for "site:website.com searchterm" BUG: 389491
This commit is contained in:
parent
2e7436c741
commit
958fc63f01
@ -128,6 +128,28 @@ void LocationBarTest::loadActionSearchTest()
|
|||||||
QCOMPARE(action.loadRequest.url(), QUrl("http://test/ttt-notsearch"));
|
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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
MainApplication::setTestModeEnabled(true);
|
MainApplication::setTestModeEnabled(true);
|
||||||
|
@ -31,4 +31,5 @@ private slots:
|
|||||||
void loadActionBasicTest();
|
void loadActionBasicTest();
|
||||||
void loadActionBookmarksTest();
|
void loadActionBookmarksTest();
|
||||||
void loadActionSearchTest();
|
void loadActionSearchTest();
|
||||||
|
void loadAction_kdebug389491();
|
||||||
};
|
};
|
||||||
|
@ -263,10 +263,13 @@ LocationBar::LoadAction LocationBar::loadAction(const QString &text)
|
|||||||
// Otherwise load as url
|
// Otherwise load as url
|
||||||
const QUrl &guessedUrl = QUrl::fromUserInput(t);
|
const QUrl &guessedUrl = QUrl::fromUserInput(t);
|
||||||
if (guessedUrl.isValid()) {
|
if (guessedUrl.isValid()) {
|
||||||
|
// We only allow space in query
|
||||||
|
if (!QzTools::containsSpace(guessedUrl.toString(QUrl::RemoveQuery))) {
|
||||||
action.type = LoadAction::Url;
|
action.type = LoadAction::Url;
|
||||||
action.loadRequest = guessedUrl;
|
action.loadRequest = guessedUrl;
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Search when creating url failed
|
// Search when creating url failed
|
||||||
action.type = LoadAction::Search;
|
action.type = LoadAction::Search;
|
||||||
|
Loading…
Reference in New Issue
Block a user