GNOME Bugzilla – Bug 619248
Can't open cbz file with [] in archive
Last modified: 2010-06-24 08:40:10 UTC
evince-2.30.1-2.fc13.x86_64 This archive doesn't work: $ unzip -l '/home/hadess/Desktop/[foobar].cbz' Archive: /home/hadess/Desktop/[foobar].cbz Length Date Time Name --------- ---------- ----- ---- 0 05-20-2010 02:15 [foobar]/ 232873 10-03-2004 17:58 [foobar]/15.jpg 216998 10-03-2004 17:53 [foobar]/11.jpg 226956 10-03-2004 18:04 [foobar]/20.jpg 230478 10-03-2004 18:14 [foobar]/26.jpg 211055 10-03-2004 17:51 [foobar]/09.jpg 246621 10-03-2004 18:03 [foobar]/19.jpg 83295 10-03-2004 18:17 [foobar]/29.jpg 237913 10-03-2004 17:50 [foobar]/08.jpg 245278 10-03-2004 18:10 [foobar]/24.jpg 183933 10-03-2004 17:54 [foobar]/12.jpg 79784 10-03-2004 17:46 [foobar]/00.jpg 227710 10-03-2004 17:48 [foobar]/06.jpg 225648 10-03-2004 17:56 [foobar]/14.jpg 237923 10-03-2004 18:07 [foobar]/22.jpg 225675 10-03-2004 18:15 [foobar]/27.jpg 250446 10-03-2004 18:06 [foobar]/21.jpg 225668 10-03-2004 18:01 [foobar]/17.jpg 225102 10-03-2004 17:49 [foobar]/07.jpg 215802 10-03-2004 18:12 [foobar]/25.jpg 225538 10-03-2004 17:52 [foobar]/10.jpg 219716 10-03-2004 17:47 [foobar]/05.jpg 225585 10-03-2004 17:59 [foobar]/16.jpg 219107 10-03-2004 17:55 [foobar]/13.jpg 193983 10-03-2004 18:16 [foobar]/28.jpg 239899 10-03-2004 18:02 [foobar]/18.jpg 177005 10-03-2004 18:08 [foobar]/23.jpg --------- ------- 5529991 27 files This one does: $ unzip -l '/home/hadess/Desktop/foobar].cbz' Archive: /home/hadess/Desktop/foobar].cbz Length Date Time Name --------- ---------- ----- ---- 0 05-20-2010 02:15 foobar]/ 232873 10-03-2004 17:58 foobar]/15.jpg 216998 10-03-2004 17:53 foobar]/11.jpg 226956 10-03-2004 18:04 foobar]/20.jpg 230478 10-03-2004 18:14 foobar]/26.jpg 211055 10-03-2004 17:51 foobar]/09.jpg 246621 10-03-2004 18:03 foobar]/19.jpg 83295 10-03-2004 18:17 foobar]/29.jpg 237913 10-03-2004 17:50 foobar]/08.jpg 245278 10-03-2004 18:10 foobar]/24.jpg 183933 10-03-2004 17:54 foobar]/12.jpg 79784 10-03-2004 17:46 foobar]/00.jpg 227710 10-03-2004 17:48 foobar]/06.jpg 225648 10-03-2004 17:56 foobar]/14.jpg 237923 10-03-2004 18:07 foobar]/22.jpg 225675 10-03-2004 18:15 foobar]/27.jpg 250446 10-03-2004 18:06 foobar]/21.jpg 225668 10-03-2004 18:01 foobar]/17.jpg 225102 10-03-2004 17:49 foobar]/07.jpg 215802 10-03-2004 18:12 foobar]/25.jpg 225538 10-03-2004 17:52 foobar]/10.jpg 219716 10-03-2004 17:47 foobar]/05.jpg 225585 10-03-2004 17:59 foobar]/16.jpg 219107 10-03-2004 17:55 foobar]/13.jpg 193983 10-03-2004 18:16 foobar]/28.jpg 239899 10-03-2004 18:02 foobar]/18.jpg 177005 10-03-2004 18:08 foobar]/23.jpg --------- ------- 5529991 27 files My guess is a problem opening the zip file with the brackets not being escaped.
hadess, thanks for reporting :) AFAIK, it's a unzip bug. Unzip has three wildcard expressions: * matches a sequence of 0 or more characters ? matches exactly 1 character [...] matches any single character found inside the brackets; ranges are specified by a beginning character, a hyphen, and an ending character. If an exclamation point or a caret (`!' or `^') follows the left bracket, then the range is complemented. If no matches are found, the specification is assumed to be a literal filename. Evince uses the following command for decompressing the pages: unzip -p -C -- '/path/file.cbz' 'path/page.jpg' we have the problem only with the page component and it only happens if the page component has the character '[' About the workaround, I can escape '[' with '\[', but I've realised that if you use '`' for quotation instead of ''', provided by g_shell_quoation() unzip unzip '/home/jjmarin/Desktop/[foobar.cbz' '\[foobar/1.jpg' unzip '/home/jjmarin/Desktop/[foobar.cbz' `[foobar/1.jpg` The second one is the most generic solution and requires less computing.
Well, what just after writing the comment I've realised it's not complete true. I will write a better analysis later on
Hi, I come up with a fix for the regex problem with unzip. Unzip accepts regex expressions for both the zip file and for the files compressed in the file. Another related issue is that unzip -Z -l , used for listing the files included on the cbz file, doesn't handle encoding filenames properly and it turns unhandled characters into '??', that is a regex expression. I found out we can use zipnote to get the list of files correctly encoded, or at least I haven't found any problem so far. So, listing the files with zipnote I can disable all the regex expression accepted by unzip (*,? and []). The funny thing is that I use the regex expression [] for disabling :)
Created attachment 162792 [details] [review] [comics] Adds comics_regex_quote(). Fixes bgo #619248
Created attachment 162805 [details] [review] [comics] Adds comics_regex_quote(). Fixes bgo #619248 Fix a memory leak and removes regex quotation for zipnote
Pushed to git master and gnome-2-30. Thanks!
Hi, this patch breaks cbz support for all the cbz files on my system. All I get is a red bar claiming that evince doesn't support the application/x-cbz mimetype and an error message in console: zipnote error: Invalid command arguments (can only specify one zip file) I reverted it and the cbz files work again. I have zip 3.0 and unzip 6.0 here.
Thanks Giacomo, I _really_ appreciate your feedback ! The patch was a little bit tricky and I overlooked a fundamental detail: to quote the input for zipnote. I attach an incremental patch for fixing this. More feedback for the new cbz code will be welcome !
Created attachment 164425 [details] [review] g_shell_quote() for zipnote
Reopening, as it's still broken :)
(In reply to comment #8) > > The patch was a little bit tricky and I overlooked a fundamental detail: to > quote the input for zipnote. I attach an incremental patch for fixing this. > I suspected something like that but didn't have the time to delve into the code. Anyway, your last patch fixes the bug here, thanks.
Applied to git master and gnome-2-30 branch and released 2.30.3