1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 18:26:34 +01:00

LocationBar: Fix resolving correct LoadAction when url contains %20

BUG: 392445
FIXED-IN: 3.0.1
This commit is contained in:
David Rosca 2018-03-28 18:54:26 +02:00
parent 7595cef9ee
commit 2f6cd7a559
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 16 additions and 2 deletions

View File

@ -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)

View File

@ -34,4 +34,5 @@ private Q_SLOTS:
void loadAction_kdebug389491();
void loadActionSpecialSchemesTest();
void loadAction_issue2578();
void loadAction_kdebug392445();
};

View File

@ -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<QString> whitelistedSchemes = {
QSL("http"), QSL("https"), QSL("ftp"), QSL("file"),