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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • 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

    Description

      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.

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes