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

WebCore::checkEncodedString asserts when javascript contains html href starting with hash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • 5.4.0 RC
    • 5.3.0 Beta1
    • WebKit
    • None

    Description

      We set html, which contains javascript, with QWebView::setHtml(). In a javascript function we define an url, which consists only the anchor portion of the url i.e. it starts with a hash. Then an assertion fails:

      ASSERTION FAILED: url.isEmpty() || isSchemeFirstChar(url[0])
      platform\KURL.cpp(307) : WebCore::checkEncodedString

      Using only the anchor portion of the url is a valid address in html. Thus it should not fail.

      The error can be reproduced with the following code snippet.

      #include <QApplication>
      #include <QWebView>
      
      void main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QWebView webView;
          webView.setHtml("<!DOCTYPE html><html><head></head><body onLoad=\"gotoAnchor();\"><script type=\"text/javascript\">function gotoAnchor() { location.href = \"#anchor\"; }</script></body></html>");
          return;
      }
      

      Reproducible only in Qt5.

      Attachments

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

        Activity

          People

            annulen Konstantin Tokarev
            qtcomsupport Qt Support
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes