Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
5.15.11, 6.2.6, 6.4.1
-
c6b2b5d80 (dev), 22b780041 (6.5), 415ee56f9 (6.4), df26edf16 (5.15)
Description
Code
#include <QApplication> #include <QtWebEngineWidgets> #include <QDebug> class MyInterceptor : public QWebEngineUrlRequestInterceptor { public: MyInterceptor(QObject *parent = nullptr) : QWebEngineUrlRequestInterceptor(parent) {} void interceptRequest(QWebEngineUrlRequestInfo &info) override { QUrl url(info.requestUrl()); qDebug() << "Intercepted" << info.requestMethod() << url; if (url.toString().startsWith("https://wiki.qt.io/QtWebEngine")) { if (url.hasFragment()) url.setFragment("Bug_Reports"); else url.setFragment("Documentation"); qDebug() << "\t...Redirecting to" << url; info.redirect(url); } } }; #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) # define setUrlRequestInterceptor setRequestInterceptor #endif int main(int argc, char *argv[]) { QApplication a(argc, argv); QWebEngineView view; QWebEngineProfile::defaultProfile()->setUrlRequestInterceptor(new MyInterceptor(&view)); view.setUrl(QUrl("https://wiki.qt.io/QtWebEngine")); view.show(); return a.exec(); }
Outcomes
- Qt 5.12.12: Qt WebEngine redirects to https://wiki.qt.io/QtWebEngine#Documentation, then redirects to https://wiki.qt.io/QtWebEngine#Bug_Reports, then loads that page successfully.
- Qt 5.15.11/6.2.6/6.4.1: Qt WebEngine redirects to https://wiki.qt.io/QtWebEngine#Documentation, then redirects to https://wiki.qt.io/QtWebEngine#Bug_Reports, then crashes.