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

QUrl::fromLocalFile invalid when file:// scheme already present

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.8, 5.9
    • Core: URL Handling
    • None

    Description

      When you construct a QUrl using QUrl::fromLocalFile and pass it a string that already contains the file:// scheme (which I think can reasonably be expected to work), you get an invalid QUrl that contains file:file:///path/to/file.

      Use case: in WebEngine we pass file paths to chromium, that can come as a local file path /path/to/file or that have been taken from a QUrl::toString, containing the scheme. We need to pass it to chromium without scheme (otherwise chromium terminates the QWebEngineProcess), so we have to remove the scheme, if present.
      Of course we could do something like if(file.startsWith("file://")) file.remove(0,7);, but for more reliability, we want to use QUrl for that. But because of said problem, the only way I have found to do this is to use QUrl::fromUserInput, which accepts other schemes, which we would prefer to avoid.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            viengelm Viktor Engelmann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes