MessageAdapter: check MIME types

QImageReader would previously improperly reject images if their MIME
type was not an exact match for the string of its supported types.
We should check against the supported MIME types instead.

GitLab: #2138
Change-Id: Id1116e930dcd120d7ec2262a1eb7504d59a675eb
This commit is contained in:
Ilyas Erdogan
2025-12-11 15:49:27 -05:00
parent 26515133e7
commit af749a9ce4

View File

@@ -563,13 +563,13 @@ MessagesAdapter::isLocalImage(const QString& mimename)
{
if (mimename.startsWith("image/")) {
QString fileFormat = mimename;
fileFormat.replace("image/", "");
QImageReader reader;
QList<QByteArray> supportedFormats = reader.supportedImageFormats();
QList<QByteArray> supportedFormats = reader.supportedMimeTypes();
auto iterator = std::find_if(supportedFormats.begin(),
supportedFormats.end(),
[fileFormat](const QByteArray& format) { return format == fileFormat; });
if (iterator != supportedFormats.end() && *iterator == "gif") {
if (iterator != supportedFormats.end() && *iterator == "image/gif") {
return {{"isAnimatedImage", true}};
}
return {{"isImage", iterator != supportedFormats.end()}};