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

QImageReader::canRead(), incorrectly returning true for any string starting with "<?xml"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.9.1
    • Image formats
    • None
    • The problem occurs on at least Linux (unsure of version) and OSX 10.11.6, using Qt 5.9.1.
    • macOS

      QImageReader::canRead(), is supposed to be a reasonably fast method of determining if a buffer contains image data.

      It seems to be setting the bar a little low though for how in depth it's checking, as it's incorrectly returning `true` for any buffer sequence starting with "<?xml".

      We have an open bug reported by one of our users, where their valid (non-image) data starts with that string. QImageReader::canRead() is incorrectly reporting that as an image file, without looking any further:

      https://github.com/sqlitebrowser/sqlitebrowser/issues/1159

      This causes problems, as our application relies on that return code to determine which data viewer to use. When canRead() gets it wrong above, that causes things to go down a wrong path.

      It should probably do a bit more checking - eg is the start of an svg tag ("<svg ") present in the first few lines? - before returning a positive value.

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

            vgt Eirik Aavitsland
            justinclift justinclift
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes