mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Fixed issue with infinite opening mailto: links in QupZilla
- when xdg-open tries to open mailto: links again in QupZilla
This commit is contained in:
parent
014ae5aff6
commit
14928e6bc6
@ -58,6 +58,7 @@ QString WebPage::s_lastUploadLocation = QDir::homePath();
|
||||
QString WebPage::s_userAgent;
|
||||
QString WebPage::s_fakeUserAgent;
|
||||
QUrl WebPage::s_lastUnsupportedUrl;
|
||||
QTime WebPage::s_lastUnsupportedUrlTime;
|
||||
QList<WebPage*> WebPage::s_livingPages;
|
||||
|
||||
WebPage::WebPage(QupZilla* mainClass)
|
||||
@ -292,15 +293,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply)
|
||||
|
||||
case QNetworkReply::ProtocolUnknownError: {
|
||||
qDebug() << "WebPage::UnsupportedContent" << url << "ProtocolUnknowError";
|
||||
|
||||
// We will open last unsupported url only once
|
||||
// (to prevent endless loop in case QDesktopServices::openUrl decide
|
||||
// to open the url again in QupZilla )
|
||||
|
||||
if (s_lastUnsupportedUrl != url) {
|
||||
s_lastUnsupportedUrl = url;
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
desktopServicesOpen(url);
|
||||
|
||||
reply->deleteLater();
|
||||
return;
|
||||
@ -323,7 +316,7 @@ void WebPage::handleUnknownProtocol(const QUrl &url)
|
||||
}
|
||||
|
||||
if (WebSettings::autoOpenProtocols.contains(protocol)) {
|
||||
QDesktopServices::openUrl(url);
|
||||
desktopServicesOpen(url);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -362,6 +355,21 @@ void WebPage::handleUnknownProtocol(const QUrl &url)
|
||||
}
|
||||
}
|
||||
|
||||
void WebPage::desktopServicesOpen(const QUrl &url)
|
||||
{
|
||||
// Open same url only once in 2 secs
|
||||
|
||||
if (s_lastUnsupportedUrl != url || QTime::currentTime() > s_lastUnsupportedUrlTime.addSecs(2)) {
|
||||
s_lastUnsupportedUrl = url;
|
||||
s_lastUnsupportedUrlTime = QTime::currentTime();
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
else {
|
||||
qWarning() << "WebPage::desktopServicesOpen Url" << url << "has already been opened!\n"
|
||||
"Ignoring it to prevent infinite loop!";
|
||||
}
|
||||
}
|
||||
|
||||
void WebPage::downloadRequested(const QNetworkRequest &request)
|
||||
{
|
||||
DownloadManager* dManager = mApp->downManager();
|
||||
@ -453,13 +461,13 @@ bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &r
|
||||
const QString &scheme = request.url().scheme();
|
||||
|
||||
if (scheme == "mailto" || scheme == "ftp") {
|
||||
QDesktopServices::openUrl(request.url());
|
||||
desktopServicesOpen(request.url());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type == QWebPage::NavigationTypeFormResubmitted) {
|
||||
QString message = tr("To show this page, QupZilla must resend request which do it again \n"
|
||||
"(like searching on making an shoping, which has been already done.)");
|
||||
"(like searching on making an shopping, which has been already done.)");
|
||||
bool result = (QMessageBox::question(view(), tr("Confirm form resubmission"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes);
|
||||
if (!result) {
|
||||
|
@ -115,11 +115,13 @@ private:
|
||||
QString chooseFile(QWebFrame* originatingFrame, const QString &oldFile);
|
||||
|
||||
void handleUnknownProtocol(const QUrl &url);
|
||||
void desktopServicesOpen(const QUrl &url);
|
||||
|
||||
static QString s_lastUploadLocation;
|
||||
static QString s_userAgent;
|
||||
static QString s_fakeUserAgent;
|
||||
static QUrl s_lastUnsupportedUrl;
|
||||
static QTime s_lastUnsupportedUrlTime;
|
||||
static QList<WebPage*> s_livingPages;
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
|
Loading…
Reference in New Issue
Block a user