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

[iOS] WebView doesn't allow reading local file without current directory

    XMLWordPrintable

    Details

    • Platform/s:
      iOS/tvOS/watchOS, macOS

      Description

      Current QDarwinWebViewPrivate::setUrl() implementation is as following.

      https://code.qt.io/cgit/qt/qtwebview.git/tree/src/plugins/darwin/qdarwinwebview.mm#n311

      void QDarwinWebViewPrivate::setUrl(const QUrl &url)
      {
          if (url.isValid()) {
              if (url.isLocalFile()) {
                  // We need to pass local files via loadFileURL and the read access should cover
                  // the directory that the file is in, to facilitate loading referenced images etc
                  [wkWebView loadFileURL:url.toNSURL()
                 allowingReadAccessToURL:QUrl(url.toString(QUrl::RemoveFilename)).toNSURL()];
              } else {
                  [wkWebView loadRequest:[NSURLRequest requestWithURL:url.toNSURL()]];
      

      If there is file structure like:

      1. /Library/Application Support/base/html/index.html
      2. /Library/Application Support/base/pdf/sample.pdf

      sample.pdf can't be access from index.html on WebView.

       

      Expectation: Allowing additional read directory can be set with add parameter for setUrl.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              stromme Christian
              Reporter:
              akizawa Akihito Izawa
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes