Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Commit

Permalink
LocationBar: Also whitelist data: scheme for loading urls
Browse files Browse the repository at this point in the history
  • Loading branch information
nowrep committed Jan 28, 2018
1 parent 67f9177 commit 9595359
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/navigation/locationbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ LocationBar::LoadAction LocationBar::loadAction(const QString &text)
// Only allow whitelisted schemes
const QSet<QString> whitelistedSchemes = {
QSL("http"), QSL("https"), QSL("ftp"), QSL("file"),
QSL("about"), QSL("qupzilla")
QSL("data"), QSL("about"), QSL("qupzilla")
};
if (whitelistedSchemes.contains(guessedUrl.scheme())) {
action.type = LoadAction::Url;
Expand Down
21 changes: 21 additions & 0 deletions tests/autotests/locationbartest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,24 @@ void LocationBarTest::loadAction_kdebug389491()
QCOMPARE(action.type, LocationBar::LoadAction::Url);
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("qupzilla:about");
QCOMPARE(action.type, LocationBar::LoadAction::Url);
QCOMPARE(action.loadRequest.url(), QUrl("qupzilla: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"));
}
1 change: 1 addition & 0 deletions tests/autotests/locationbartest.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ private slots:
void loadActionBookmarksTest();
void loadActionSearchTest();
void loadAction_kdebug389491();
void loadActionSpecialSchemesTest();
};

0 comments on commit 9595359

Please sign in to comment.