mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 19:12:11 +01:00
GreaseMonkey - Check content type of url *.user.js
- Do not stop loading the page with url matching user script - Only match clicked links BUG: 467459 Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
d3b1271e6d
commit
4772efb483
|
@ -58,6 +58,13 @@ void GM_Downloader::scriptDownloaded()
|
|||
return;
|
||||
}
|
||||
|
||||
QString contentType = m_reply->header(QNetworkRequest::ContentTypeHeader).toString();
|
||||
if (!(contentType.startsWith(QSL("text/plain")) || contentType.startsWith(QSL("text/javascript")))) {
|
||||
qWarning() << "GreaseMonkey: Unsupported content type" << contentType;
|
||||
Q_EMIT error();
|
||||
return;
|
||||
}
|
||||
|
||||
const QByteArray response = QString::fromUtf8(m_reply->readAll()).toUtf8();
|
||||
|
||||
if (!response.contains(QByteArray("// ==UserScript=="))) {
|
||||
|
|
|
@ -107,11 +107,10 @@ bool GM_Plugin::acceptNavigationRequest(WebPage *page, const QUrl &url, QWebEngi
|
|||
Q_UNUSED(page)
|
||||
Q_UNUSED(isMainFrame)
|
||||
|
||||
bool navigationType = type == QWebEnginePage::NavigationTypeLinkClicked || type == QWebEnginePage::NavigationTypeRedirect;
|
||||
bool navigationType = type == QWebEnginePage::NavigationTypeLinkClicked;
|
||||
|
||||
if (navigationType && url.toString().endsWith(QLatin1String(".user.js"))) {
|
||||
if (navigationType && url.fileName().endsWith(QLatin1String(".user.js"))) {
|
||||
m_manager->downloadScript(url);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user