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

QMimeData does not escape square brackets in text/uri-list

    XMLWordPrintable

Details

    • Linux/Wayland, macOS
    • 31753e722 (dev), 5e936b60f (dev), 6deb5098a (6.9), de3cf05b7 (6.9), 52a5ac769 (6.8), 8f5e26f51 (6.8)

    Description

      When a URL contains square brackets, QMimeData, doesn't escape them when building a file URI for drag-and-drop data. The URL spec (RFC 3986) states that square brackets are always invalid in  URLs except when used to enclose an IP address, so some strict URI   parsers will reject file URIs containing them.

       

      One liner demonstrating the issue:

      python -c 'from PySide6.QtCore import QUrl, QMimeData; md = QMimeData(); md.setUrls([QUrl.fromLocalFile("/t e[st]")]); print(bytes(md.data("text/uri-list")).decode())'
      
      file:///t%20e[st]
      

       

      We see that the space has been escaped as %20 but the  ch[ and ]aracters have not been escaped.

       

        This specifically causes problems on macOS because Apple's NSURL is
        one of those strict URI implementations that will reject file URIs
        with brackets.

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            kovidgoyal Kovid Goyal
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There is 1 open Gerrit change