Giter VIP home page Giter VIP logo

Comments (8)

kkofler avatar kkofler commented on August 17, 2024

I am that "very helpful person". ;-)

The main offending function is this one:
https://github.com/tumic0/QtPBFImagePlugin/blob/master/src/pbfhandler.cpp#L23
which does not actually look inside the GZIP.

It is important that your plugin does not falsely claim to support files, because Qt will otherwise automatically attempt to use it for files that are not actually supported.

from qtpbfimageplugin.

tumic0 avatar tumic0 commented on August 17, 2024

Well, the canRead() logic could maybe be a little bit improved (the question is at what price), but the problem with the uncertainty will still remain (until one would do a full decompression of the file and full GPB parsing). The core problem is neither GZIP and especially not GPB were designed to be easily recognisable.

But if anyone is trying to open an GZIP/PBF file as an image (why would someone do that?) he will get an error during reading the image which he can get with any other image plugin on any broken image, so he must be prepared to handle such error anyway. The only real problem I can imagine is another conflicting image plugin that also reads GZIP/PBF data. Is there such a plugin?

from qtpbfimageplugin.

tumic0 avatar tumic0 commented on August 17, 2024

Ok, I have missed the SVGZ example from the first comment, so there might be a colliding plugin. But still I would be interested in the real collision as Qt looks first on the file extension.

from qtpbfimageplugin.

tumic0 avatar tumic0 commented on August 17, 2024

Qt's SVG image plugin works exactly the same way as QtPBFImagePlugin does: qsvgiohandler.cpp

So let's do it this way - You report the bug to Qt and if they decide that it is not the way canRead() shall work and the test shall be changed, I will change it like they did.

from qtpbfimageplugin.

kkofler avatar kkofler commented on August 17, 2024

The collision happens in the Jami application, when it tries to load an avatar into a QImage. I guess there is no file extension at all there, QImage has to figure out the type from what it guesses.

The fact that both the SVG plugin and this plugin claim the same files indeed makes it clear that both are broken.

The net result is that the entire application crashes due to https://lists.qt-project.org/pipermail/development/2020-April/039228.html (where the consensus among Qt developers appears to be that Jami is at fault for using QImage without a QGuiApplication).

from qtpbfimageplugin.

tumic0 avatar tumic0 commented on August 17, 2024

The fact that both the SVG plugin and this plugin claim the same files indeed makes it clear that both are broken.

It's really not that easy. There are very good reasons why Qt's SVG plugin as well as QtPBFImagePlugin work the way they work. The canRead() function is part of autodetection that has to be fast and may fail (there may be even more plugins for the same data). This is why there are ways to use the exact plugin you want. Also note, that it is not acceptable, that the plugin does a full extract of the data (and there is data where you can't to do it another way) in canRead() to decide. Imagine you have three plugins doing a full extract of a 2GB file just to say "no, it is not my data"...

So as already said, it has to be carefully decided what is the optimal approach. And until Qt makes the decision (changes the SVG plugin detection), I won't change it neither. Reopen if that happens.

from qtpbfimageplugin.

kkofler avatar kkofler commented on August 17, 2024

You can do streaming decompression of gzip files, i.e., decompress only the first n bytes, which is exactly what is really needed here.

from qtpbfimageplugin.

tumic0 avatar tumic0 commented on August 17, 2024

I have added this check in a298cfc as it seems not to have a that significant performance drawback (maybe with huge SVG files, but I do not have the resources to test it). But you can still not expect the autodetection to be 100%...

from qtpbfimageplugin.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.