1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-13 10:32:11 +01:00

LocationBar: Also whitelist data: scheme for loading urls

This commit is contained in:
David Rosca 2018-01-28 15:45:54 +01:00
parent ae3aebc06c
commit deca7f7399
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 25 additions and 3 deletions

View File

@ -74,9 +74,9 @@ void LocationBarTest::loadActionBasicTest()
action = LocationBar::loadAction("not url with spaces"); action = LocationBar::loadAction("not url with spaces");
QCOMPARE(action.type, LocationBar::LoadAction::Search); QCOMPARE(action.type, LocationBar::LoadAction::Search);
action = LocationBar::loadAction("qupzilla:about"); action = LocationBar::loadAction("falkon:about");
QCOMPARE(action.type, LocationBar::LoadAction::Url); QCOMPARE(action.type, LocationBar::LoadAction::Url);
QCOMPARE(action.loadRequest.url(), QUrl("qupzilla:about")); QCOMPARE(action.loadRequest.url(), QUrl("falkon:about"));
} }
void LocationBarTest::loadActionBookmarksTest() void LocationBarTest::loadActionBookmarksTest()
@ -152,4 +152,25 @@ void LocationBarTest::loadAction_kdebug389491()
QCOMPARE(action.loadRequest.url(), QUrl("http://website.com?search=searchterm and another")); QCOMPARE(action.loadRequest.url(), QUrl("http://website.com?search=searchterm and another"));
} }
void LocationBarTest::loadActionSpecialSchemesTest()
{
LocationBar::LoadAction action;
action = LocationBar::loadAction("data:image/png;base64,xxxxx");
QCOMPARE(action.type, LocationBar::LoadAction::Url);
QCOMPARE(action.loadRequest.url(), QUrl("data:image/png;base64,xxxxx"));
action = LocationBar::loadAction("falkon:about");
QCOMPARE(action.type, LocationBar::LoadAction::Url);
QCOMPARE(action.loadRequest.url(), QUrl("falkon:about"));
action = LocationBar::loadAction("file:test.html");
QCOMPARE(action.type, LocationBar::LoadAction::Url);
QCOMPARE(action.loadRequest.url(), QUrl("file:test.html"));
action = LocationBar::loadAction("about:blank");
QCOMPARE(action.type, LocationBar::LoadAction::Url);
QCOMPARE(action.loadRequest.url(), QUrl("about:blank"));
}
FALKONTEST_MAIN(LocationBarTest) FALKONTEST_MAIN(LocationBarTest)

View File

@ -32,4 +32,5 @@ private slots:
void loadActionBookmarksTest(); void loadActionBookmarksTest();
void loadActionSearchTest(); void loadActionSearchTest();
void loadAction_kdebug389491(); void loadAction_kdebug389491();
void loadActionSpecialSchemesTest();
}; };

View File

@ -269,7 +269,7 @@ LocationBar::LoadAction LocationBar::loadAction(const QString &text)
// Only allow whitelisted schemes // Only allow whitelisted schemes
const QSet<QString> whitelistedSchemes = { const QSet<QString> whitelistedSchemes = {
QSL("http"), QSL("https"), QSL("ftp"), QSL("file"), QSL("http"), QSL("https"), QSL("ftp"), QSL("file"),
QSL("about"), QSL("qupzilla") QSL("data"), QSL("about"), QSL("falkon")
}; };
if (whitelistedSchemes.contains(guessedUrl.scheme())) { if (whitelistedSchemes.contains(guessedUrl.scheme())) {
action.type = LoadAction::Url; action.type = LoadAction::Url;