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 562143 - Evince a bit naive about filetypes
Evince a bit naive about filetypes
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: backends
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-24 16:46 UTC by Bastien Nocera
Modified: 2008-12-21 01:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix cb7 mime-type support in comics backend (622 bytes, patch)
2008-12-20 12:01 UTC, Juanjo Marín
none Details | Review

Description Bastien Nocera 2008-11-24 16:46:33 UTC
1. Get or create a CBZ (zip) comic book archive
2. Rename the file to .cbr

Evince tells you it can't handle zip files, when it should know it's a .cbz comic book.
Comment 1 Carlos Garcia Campos 2008-11-29 12:09:56 UTC
Fixed in svn trunk. Thanks for reporting. 
Comment 2 Juanjo Marín 2008-12-02 22:34:09 UTC
There is an error with cbz files. The function ev_file_get_mime_type returns "application/zip" instead of "application/x-zip". The direct workaround is to add this string to the conditional expression for the cbz files, it doesn't hurts to anybody, and, of course, to report this error.

As far I know, I _think_ I can back track this bug until the g_content_type_guess at the file  gcontenttype.c from GLib.  

Can anyone be so kind of checking it out and report the error ? :-)
Comment 3 Bastien Nocera 2008-12-02 22:45:12 UTC
application/x-zip doesn't exist anywhere in shared-mime-info, so it's unlikely to be a glib issue.
Comment 4 Juanjo Marín 2008-12-02 23:14:18 UTC
Thank you Bastien, you're very quick :-). Awesome !!!

OK, so then I guess is enough to change "application/x-zip" for "application/zip" in the conditional expression for the cbz files.

the silly "patch" I propose is then:

Index: backend/comics/comics-document.c
===================================================================
--- backend/comics/comics-document.c	(revisión: 3287)
+++ backend/comics/comics-document.c	(copia de trabajo)
@@ -131,7 +131,7 @@
 			g_strdup_printf ("unrar vb -c- -- %s", quoted_file);
 		comics_document->regex_arg = FALSE;
 	} else if (!strcmp (mime_type, "application/x-cbz") ||
-		   !strcmp (mime_type, "application/x-zip")) {
+		   !strcmp (mime_type, "application/zip")) {
 		comics_document->extract_command =
 			g_strdup ("unzip -p -C");
 		list_files_command = 


Comment 5 Juanjo Marín 2008-12-02 23:25:52 UTC
I find a similar issue with the cb7 files. In the same way, I think is sensible to add the string "application/x-7z-compressed" -the mime type for 7z files- to its conditional expression.

However, the mime type detected for the application is "application/octet-stream". I don't understand why.
Comment 6 Bastien Nocera 2008-12-02 23:30:39 UTC
That's because the definition of the application/x-7z-compressed mime-type doesn't have any magic.
Comment 7 Carlos Garcia Campos 2008-12-03 11:01:24 UTC
(In reply to comment #3)
> application/x-zip doesn't exist anywhere in shared-mime-info, so it's unlikely
> to be a glib issue.
> 

Yes, it's indeed my fault :-P

(In reply to comment #4)
> Thank you Bastien, you're very quick :-). Awesome !!!
> 
> OK, so then I guess is enough to change "application/x-zip" for
> "application/zip" in the conditional expression for the cbz files.
> 
> the silly "patch" I propose is then:
> 
> Index: backend/comics/comics-document.c
> ===================================================================
> --- backend/comics/comics-document.c    (revisión: 3287)
> +++ backend/comics/comics-document.c    (copia de trabajo)
> @@ -131,7 +131,7 @@
>                         g_strdup_printf ("unrar vb -c- -- %s", quoted_file);
>                 comics_document->regex_arg = FALSE;
>         } else if (!strcmp (mime_type, "application/x-cbz") ||
> -                  !strcmp (mime_type, "application/x-zip")) {
> +                  !strcmp (mime_type, "application/zip")) {
>                 comics_document->extract_command =
>                         g_strdup ("unzip -p -C");
>                 list_files_command = 
> 

Applied, thanks! :-)
Comment 8 Bastien Nocera 2008-12-03 11:17:36 UTC
(In reply to comment #6)
> That's because the definition of the application/x-7z-compressed mime-type
> doesn't have any magic.

I added magic for 7z files to shared-mime-info this morning.
Comment 9 Juanjo Marín 2008-12-03 18:53:01 UTC
Thank you Bastien, you're my man :-)

I built evince with jhbuild, and, by now, the mime type detected by evince is
"application/octet-stream".

Is the change commited on the svn ?
Comment 10 Juanjo Marín 2008-12-03 22:59:31 UTC
Another problem with the cb7 support is that cb7 files are not shown in the File Chooser Dialog.

I guess that this is because mime type for cb7 files [1] is not detected correctly. 

[1] I don't know which is the correct name of the mime type for cb7 files, evince file chooser dialog shows (or tries to show) files with the mime type "application/x-cb7". However, the property tab of my system _ubuntu-8.04_ indicates that cb7 files are of mime type "application/x-extension-cb7" and this is confusing to me.

PS: Bastien, I'm a newbie and I don't understand very well all this shared-mime-inf stuff. JHbuild download the lastest published version, shared-mime-info-0.51. 
Comment 11 Bastien Nocera 2008-12-03 23:28:48 UTC
shared-mime-info 0.51 is the latest release, but you'd need to get the CVS version to get it working. As for cb7 files, they're not in shared-mime-info. Feel free to file a bug at bugs.freedesktop.org and I'll add it there.
Comment 12 Juanjo Marín 2008-12-04 22:28:49 UTC
I've opened a bug for cb7 support 

https://bugs.freedesktop.org/show_bug.cgi?id=18887

However, the fix for cb7 support needs more work because the command for listing the files doesn't work. I'll try to fix it in the following days if I'don't go out too much :-)
Comment 13 Juanjo Marín 2008-12-09 23:52:14 UTC
I've submitted a patch for bug 18887 in shared-mime-info (it haven't be applied yet). With this patch and the one by Bastien Nocera we have everything in shared-mime-info for the comic book backend.

We only need to add this small patch for cb7 files to have the mime support for all the comic book formats:

===================================================================
--- backend/comics/comics-document.c	(revisión: 3295)
+++ backend/comics/comics-document.c	(copia de trabajo)
@@ -137,7 +137,8 @@
 		list_files_command = 
 			g_strdup_printf ("zipinfo -1 -- %s", quoted_file);
 		comics_document->regex_arg = TRUE;
-	} else if (!strcmp (mime_type, "application/x-cb7")) {
+	} else if (!strcmp (mime_type, "application/x-cb7") ||
+		   !strcmp (mime_type, "application/x-7z-compressed")) {
 		comics_document->extract_command =
 			g_strdup ("7zr x -so");
 		list_files_command = 


PS: Now we have to fix the rar (bug 552074) and 7z support. I will open a bug report for the 7z problem I've detected.
Comment 14 Juanjo Marín 2008-12-20 11:58:51 UTC
Hi, Bastien has applied the patch for bug 18887 for share-mime-info (thank you!) and the only thing left to fix the mime-type support for cb7 files is to apply a pretty simple patch. I attach the patch (I missed a line when I quoted on the previous comment).
Comment 15 Juanjo Marín 2008-12-20 12:01:37 UTC
Created attachment 125045 [details] [review]
Fix cb7 mime-type support in comics backend
Comment 16 Juanjo Marín 2008-12-21 01:02:30 UTC
Related (sort of): Bug 565174 – Evince crashes with cb7 files
http://bugzilla.gnome.org/show_bug.cgi?id=565174