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

[WebView] Fixed loading of bookmarklets

Closes #1288
This commit is contained in:
David Rosca 2014-04-12 22:24:42 +02:00
parent e9a9a768cc
commit 45635f6da8

View File

@ -180,17 +180,14 @@ void WebView::load(const LoadRequest &request)
{
const QUrl reqUrl = request.url();
if (reqUrl.scheme() == QLatin1String("javascript")) {
// Getting scriptSource from PercentEncoding to properly load bookmarklets
// First check if url is percent encoded (let's just look for space)
QString scriptSource;
if (reqUrl.path().trimmed().contains(' ')) {
scriptSource = reqUrl.toString().mid(11);
}
else {
scriptSource = QUrl::fromPercentEncoding(reqUrl.toString().mid(11).toUtf8());
}
page()->mainFrame()->evaluateJavaScript(scriptSource);
if (reqUrl.scheme() == QL1S("javascript")) {
const QString scriptSource = reqUrl.toString().mid(11);
// Is the javascript source percent encoded or not?
// Looking for % character in source should work in most cases
if (scriptSource.contains(QL1C('%')))
page()->mainFrame()->evaluateJavaScript(QUrl::fromPercentEncoding(scriptSource.toUtf8()));
else
page()->mainFrame()->evaluateJavaScript(scriptSource);
return;
}