X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=comics%2Fcomics-document.c;h=7f53f85a1da0374307ec321a078cb76cbbab9232;hb=9f20012d6372450a60b93744367a3b718e7866c6;hp=93cd009a294062b7f8aeabb248773e5672bd787a;hpb=3ec63537add6165440f67c6c6ad8413a40724c13;p=evince.git diff --git a/comics/comics-document.c b/comics/comics-document.c index 93cd009a..7f53f85a 100644 --- a/comics/comics-document.c +++ b/comics/comics-document.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "comics-document.h" #include "ev-document-misc.h" @@ -40,6 +39,7 @@ struct _ComicsDocument GSList *page_names; int n_pages; char *extract_command; + gboolean regex_arg; }; typedef struct _ComicsDocumentClass ComicsDocumentClass; @@ -67,6 +67,36 @@ G_DEFINE_TYPE_WITH_CODE ( comics_document_document_thumbnails_iface_init); } ); +static char * +comics_regex_quote (const char *s) +{ + char *ret, *d; + + d = ret = g_malloc (strlen (s) * 2 + 3); + + *d++ = '\''; + + for (; *s; s++, d++) { + switch (*s) { + case '?': + case '|': + case '[': + case ']': + case '*': + case '\\': + case '\'': + *d++ = '\\'; + break; + } + *d = *s; + } + + *d++ = '\''; + *d = '\0'; + + return ret; +} + static gboolean comics_document_load (EvDocument *document, const char *uri, @@ -92,11 +122,13 @@ comics_document_load (EvDocument *document, 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")) { comics_document->extract_command = g_strdup ("unzip -p -C"); list_files_command = g_strdup_printf ("zipinfo -1 -- %s", quoted_file); + comics_document->regex_arg = TRUE; } g_free (quoted_file); @@ -164,22 +196,8 @@ comics_document_save (EvDocument *document, GError **error) { ComicsDocument *comics_document = COMICS_DOCUMENT (document); - GnomeVFSURI *source, *target; - GnomeVFSResult ret; - - source = gnome_vfs_uri_new (comics_document->archive); - target = gnome_vfs_uri_new (uri); - - ret = gnome_vfs_xfer_uri (source, target, - GNOME_VFS_XFER_DEFAULT, - GNOME_VFS_XFER_ERROR_MODE_ABORT, - GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE, - NULL, NULL); - - gnome_vfs_uri_unref (source); - gnome_vfs_uri_unref (target); - - return ret == GNOME_VFS_OK; + + return ev_xfer_uri_simple (comics_document->archive, uri, error); } static int @@ -470,8 +488,13 @@ extract_argv (EvDocument *document, gint page) char *command_line, *quoted_archive, *quoted_filename; quoted_archive = g_shell_quote (comics_document->archive); - quoted_filename = g_shell_quote ( - g_slist_nth_data (comics_document->page_names, page)); + if (comics_document->regex_arg) { + quoted_filename = comics_regex_quote ( + g_slist_nth_data (comics_document->page_names, page)); + } else { + quoted_filename = g_shell_quote ( + g_slist_nth_data (comics_document->page_names, page)); + } command_line = g_strdup_printf ("%s -- %s %s", comics_document->extract_command,