After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 123979 - gnome-vfs thinks some of my zip files are mp3s
gnome-vfs thinks some of my zip files are mp3s
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: MIME and file/program mapping
cvs (head)
Other Linux
: Normal normal
: ---
Assigned To: gnome-vfs maintainers
gnome-vfs maintainers
: 131828 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-10-06 21:30 UTC by Bastien Nocera
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gnome-vfs mp3 zip fix (946 bytes, patch)
2003-10-06 21:30 UTC, Bastien Nocera
none Details | Review
proposed fix (1.43 KB, patch)
2003-11-15 14:19 UTC, Christophe Fergeau
none Details | Review
updated patch (1.29 KB, patch)
2003-11-16 11:53 UTC, Christophe Fergeau
none Details | Review

Description Bastien Nocera 2003-10-06 21:30:18 UTC
That'd probably be because the gnome-vfs functions to search for an MPEG
header actually go quite deep in the file, and these were zipped mp3s.

Patch attached.
Comment 1 Bastien Nocera 2003-10-06 21:30:55 UTC
Created attachment 20518 [details] [review]
gnome-vfs mp3 zip fix
Comment 2 Christophe Fergeau 2003-10-06 21:53:49 UTC
How does that happen exactly (ie using which function)? 
Iirc, gnome-vfs uses looks_like_mp3 only if the file didn't match any
other mime sniffing pattern. Is your zip file properly sniffed as a
zip file, or is it only recognised by looking at its extension?
Comment 3 Bastien Nocera 2003-10-07 09:17:19 UTC
from gnome-vfs-mime-magic:
# Disable zip because detecting StarOffice files correctly is more
imporant in the release
# than detecting the occasional zip file without an extension

Zip files, just like .gz files, aren't detected by content.
Comment 4 Bastien Nocera 2003-10-07 09:58:26 UTC
(Probably a good idea to move that code, although simple, to a
looks_like_zip) or something.
Comment 5 Christophe Fergeau 2003-10-07 10:01:20 UTC
There is special handling for application/x-gzip files in
gnome-vfs-mime.c, maybe zip files should be handled the same way,
things would still be ugly, but at least this would be consistent :)
Comment 6 Christophe Fergeau 2003-11-15 14:19:32 UTC
Created attachment 21472 [details] [review]
proposed fix
Comment 7 Christophe Fergeau 2003-11-15 14:21:02 UTC
If you reenable zip sniffing in gnome-mime-data and apply this patch,
I think your zip files will no longer be misdetected as mp3s
(sorry about the patch, there are some indentation changes mixed with
the real changes :-/)
Comment 8 Bastien Nocera 2003-11-15 23:29:32 UTC
I thought that zip detection could bring up false positives, as some
formats rely on zip compression (like some StarOffice files are tar.gz
with a different extension).
If you can disprove that, the fix looks good to me.
Comment 9 Christophe Fergeau 2003-11-15 23:47:55 UTC
Yeah, you can get some false detection (though .tar.gz files won't be
detected as zip files imo), that's why files which are sniffed as
application/x-gzip or application/zip are special cased. When such a
file is found, gnome-vfs tries to guess its mime type using its
extension, and returns this mime type if it finds any. 
Currently, only gzip files are special cased in this way. The patch
also special cases zip files.
Comment 10 Bastien Nocera 2003-11-16 11:14:49 UTC
"though .tar.gz files won't be detected as zip files imo"
But StarOffice files won't be detected as StarOffice files but zip
files...
Comment 11 Christophe Fergeau 2003-11-16 11:36:01 UTC
I was referring to your "(like some StarOffice files are tar.gz
with a different extension)" comment, it looks like you actually meant
"zip with a different extension"

What the patch does is "if we mime sniff a zip or gzip file, don't
return application/(x-g)zip, but guess the mime type using the
extension, and return that mime type instead". I guess this would
properly identify StarOffice files, and other zip compressed file formats.
Comment 12 Bastien Nocera 2003-11-16 11:40:50 UTC
Shouldn't it be:
result = gnome_vfs_mime_type_from_name_or_default (file_name,
"application/x-zip");  and the likes?
Comment 13 Christophe Fergeau 2003-11-16 11:53:16 UTC
Created attachment 21493 [details] [review]
updated patch
Comment 14 Christophe Fergeau 2003-11-16 11:54:17 UTC
Good point, this simplifies the code a bit, here is another patch.
Comment 15 Christophe Fergeau 2004-01-09 11:57:49 UTC
Never got around to committing that, is it still happening now that
gnome-vfs is using the shared mime database ?
Comment 16 Christophe Fergeau 2004-01-18 20:54:38 UTC
*** Bug 131828 has been marked as a duplicate of this bug. ***
Comment 17 Christophe Fergeau 2004-01-18 20:59:26 UTC
I committed this patch to the 2-4 branch, this is already fixed in HEAD