]> www.fi.muni.cz Git - evince.git/commitdiff
Do not trust file extensions when getting the command needed to uncompress
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sat, 29 Nov 2008 12:09:17 +0000 (12:09 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Sat, 29 Nov 2008 12:09:17 +0000 (12:09 +0000)
2008-11-29  Carlos Garcia Campos  <carlosgc@gnome.org>

* backend/comics/comics-document.c: (comics_document_load):

Do not trust file extensions when getting the command needed to
uncompress comic documents. Fixes bug #562143.

svn path=/trunk/; revision=3280

ChangeLog
backend/comics/comics-document.c

index 3bb920b9ac34792e21731066111817a6210f13d9..5e38e6043d31adcd18ba78170adbeab6c5a87daf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-29  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * backend/comics/comics-document.c: (comics_document_load):
+
+       Do not trust file extensions when getting the command needed to
+       uncompress comic documents. Fixes bug #562143.
+       
 2008-11-29  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * libdocument/ev-document-factory.c: (get_document_from_uri),
index b2f7b7ac728ff838e5cd1fd263f5dc752adf5411..6ea6a7a1cdc741a165834c8eac6e1d22217ed1e3 100644 (file)
@@ -109,10 +109,8 @@ comics_document_load (EvDocument *document,
 {
        ComicsDocument *comics_document = COMICS_DOCUMENT (document);
        GSList *supported_extensions;
-       GFile *file;
-       GFileInfo *file_info;
        gchar *list_files_command = NULL, *std_out, *quoted_file;
-       const gchar *mime_type = NULL;
+       gchar *mime_type;
        gchar **cbr_files;
        gboolean success;
        int i, retval;
@@ -121,24 +119,19 @@ comics_document_load (EvDocument *document,
        g_return_val_if_fail (comics_document->archive != NULL, FALSE);
 
        quoted_file = g_shell_quote (comics_document->archive);
-       file = g_file_new_for_uri (uri);
-       file_info = g_file_query_info (file,
-                                      G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-                                      0, NULL, NULL);
-       if (file_info != NULL) {
-               mime_type = g_file_info_get_content_type (file_info);
-       }
-       g_object_unref (file);
+       mime_type = ev_file_get_mime_type (uri, FALSE, NULL);
 
        /* FIXME, use proper cbr/cbz mime types once they're
         * included in shared-mime-info */
-       if (!strcmp (mime_type, "application/x-cbr")) {
+       if (!strcmp (mime_type, "application/x-cbr") ||
+           !strcmp (mime_type, "application/x-rar")) {
                comics_document->extract_command =
                        g_strdup ("unrar p -c- -ierr");
                list_files_command =
                        g_strdup_printf ("unrar vb -c- -- %s", quoted_file);
                comics_document->regex_arg = FALSE;
-       } else if (!strcmp (mime_type, "application/x-cbz")) {
+       } else if (!strcmp (mime_type, "application/x-cbz") ||
+                  !strcmp (mime_type, "application/x-zip")) {
                comics_document->extract_command =
                        g_strdup ("unzip -p -C");
                list_files_command = 
@@ -152,7 +145,7 @@ comics_document_load (EvDocument *document,
                comics_document->regex_arg = TRUE;
        }
 
-       g_object_unref (file_info);
+       g_free (mime_type);
        g_free (quoted_file);
 
        /* Get list of files in archive */