fix: invalid bres url may cause webengine to crash. such as bres://upload.wikimedia.org/wikipedia/commons/2/23/Icons-mini-file_acrobat.gif

This commit is contained in:
xiaoyifang 2022-01-09 11:36:48 +08:00
parent bd6cc8b9c9
commit 3f11826918
2 changed files with 7 additions and 5 deletions

View file

@ -518,7 +518,7 @@ void ArticleView::loadFinished( bool )
{
setZoomFactor(cfg.preferences.zoomFactor);
QUrl url = ui.definition->url();
qDebug() << "article view loaded url:" << url;
qDebug() << "article view loaded url:" << url.url ().left (200);
QVariant userDataVariant = ui.definition->property("currentArticle");

View file

@ -9,15 +9,17 @@ void ResourceSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
QNetworkRequest request;
request.setUrl(url);
QNetworkReply *reply = this->mManager.createRequest(QNetworkAccessManager::GetOperation, request, NULL);
connect(reply, &QNetworkReply::finished, requestJob, [=]() {
if (reply->error() == QNetworkReply::ContentNotFoundError) {
requestJob->fail(QWebEngineUrlRequestJob::UrlNotFound);
return;
}
qDebug() << "resource scheme handler receive finished signal:" << reply->request().url();
if (reply->error() != QNetworkReply::NoError) {
qDebug() << "resource handler failed:" << reply->error() << ":" << reply->request().url();
requestJob->fail(QWebEngineUrlRequestJob::RequestFailed);
return;
}
QMimeType mineType = db.mimeTypeForUrl(url);
QString contentType = mineType.name();
// Reply segment