+2006-02-03 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * comics/comics-document.c: (comics_regex_quote),
+ (comics_document_load), (extract_argv):
+
+ Correcly quote regexp before passing it to unzip.
+
2006-02-01 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
* shell/ev-page-cache.c: (build_height_to_page),
GSList *page_names;
int n_pages;
char *extract_command;
+ gboolean regex_arg;
};
typedef struct _ComicsDocumentClass ComicsDocumentClass;
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,
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);
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,