From: Carlos Garcia Campos Date: Sat, 29 Nov 2008 12:09:17 +0000 (+0000) Subject: Do not trust file extensions when getting the command needed to uncompress X-Git-Tag: EVINCE_2_25_2~6 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=feeec13cf60423b15059f5e30cf3fb5763cd3922;p=evince.git Do not trust file extensions when getting the command needed to uncompress 2008-11-29 Carlos Garcia Campos * 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 --- diff --git a/ChangeLog b/ChangeLog index 3bb920b9..5e38e604 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-11-29 Carlos Garcia Campos + + * 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 * libdocument/ev-document-factory.c: (get_document_from_uri), diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c index b2f7b7ac..6ea6a7a1 100644 --- a/backend/comics/comics-document.c +++ b/backend/comics/comics-document.c @@ -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 */