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

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

XMLWordPrintable

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

      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.

       

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

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

              Created:
              Updated:
              Resolved: