Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109357

[REG 5.12 -> 5.15/6.x] QWebEngineUrlRequestInterceptor: Multiple redirects crashes the application

    XMLWordPrintable

Details

    • 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

      Attachments

        For Gerrit Dashboard: QTBUG-109357
        # Subject Branch Project Status CR V

        Activity

          People

            mibrunin Michael Bruning
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes