[Gwenview] Use url.fileName() to determine MIME type of remote URLs
AbandonedPublic

Authored by cfeck on Feb 22 2017, 10:07 PM.

Details

Summary

I checked the source for mimeTypeForUrl(). It looks correct for local files, but tries to open remote files with the same path as local files, which longs wrong to me.

Additionally, QMimeDatabase::mimeTypeForUrl() does not work with http URLs, so use mimeTypeForFileName() directly instead for remote files.

The better fix would be to really download the file to check the type, but my KIO foo is rather limited.

Test Plan

Works according to investigation in bugzilla.

See https://bugs.kde.org/show_bug.cgi?id=343796

Diff Detail

Repository
R260 Gwenview
Lint
Lint Skipped
Unit
Unit Tests Skipped
cfeck created this revision.Feb 22 2017, 10:07 PM
dfaure edited edge metadata.Feb 25 2017, 11:09 AM

You are right that there was a bug in mimeTypeForUrl (doing unnecessary work, unlikely to return wrong results), fixed in https://codereview.qt-project.org/186714, thanks for noticing.

I however disagree with using file extensions over HTTP, they are meaningless (which is why I wrote mimeTypeForUrl that way). You can write a perl cgi script that returns an image, your URL will end in .pl and yet you'll get an image...

Yes the real solution is KIO::mimeType or KIO::stat (or even better, KIO::get and putting the slave on hold, in case you decide to actually retrieve that file afterwards, to avoid making a separate request for it) but that's async, you need to modify the code here to not assume the mimetype information is available immediately.

dfaure requested changes to this revision.Jun 23 2017, 8:00 PM
This revision now requires changes to proceed.Jun 23 2017, 8:00 PM
cfeck abandoned this revision.May 16 2019, 10:53 PM
Restricted Application added a project: Gwenview. ยท View Herald TranscriptMay 16 2019, 10:53 PM