After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 792754 - comics: Fix reading CBZ files created on macOS
comics: Fix reading CBZ files created on macOS
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: comics
unspecified
Other All
: Normal normal
: ---
Assigned To: Evince Comics Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-01-21 15:23 UTC by Bastien Nocera
Modified: 2018-01-23 16:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
comics: Fix reading CBZ files created on macOS (2.23 KB, patch)
2018-01-21 15:23 UTC, Bastien Nocera
none Details | Review
comics: Fix reading CBZ files created on macOS (2.29 KB, patch)
2018-01-21 15:27 UTC, Bastien Nocera
none Details | Review
comics: Fix reading CBZ files created on macOS (2.29 KB, patch)
2018-01-23 14:10 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2018-01-21 15:23:39 UTC
.
Comment 1 Bastien Nocera 2018-01-21 15:23:43 UTC
Created attachment 367177 [details] [review]
comics: Fix reading CBZ files created on macOS

macOS' builtin ZIP file format support will add AppleDouble files to the
archives in order to store information that would otherwise be stored in
extended attributes or resource forks, in a way that's unlikely to be
meddled with by applications that don't know how to handle this
metadata.

But when we store images in such a ZIP file, we'll end up with files
named "__MACOSX/dirname/._page0001.JPG" for example, which our current
code will interpret as being images, and thus pages in our comic.
They're not. As the AppleDouble files always have the "._" prefix,
ignore those.
Comment 2 Bastien Nocera 2018-01-21 15:24:53 UTC
Test file here, select "Cliquer ici pour démarrer le téléchargement" to start the download:
http://www.abandonware-magazines.org/download.php?num=2223

Rename to .CBZ after download.
Comment 3 Bastien Nocera 2018-01-21 15:27:04 UTC
Created attachment 367178 [details] [review]
comics: Fix reading CBZ files created on macOS

macOS' builtin ZIP file format support will add AppleDouble files to the
archives in order to store information that would otherwise be stored in
extended attributes or resource forks, in a way that's unlikely to be
meddled with by applications that don't know how to handle this
metadata.

But when we store images in such a ZIP file, we'll end up with files
named "__MACOSX/dirname/._page0001.JPG" for example, which our current
code will interpret as being images, and thus pages in our comic.
They're not. As the AppleDouble files always have the "._" prefix,
ignore those.

See https://en.wikipedia.org/wiki/AppleSingle_and_AppleDouble_formats
Comment 4 Carlos Garcia Campos 2018-01-23 11:09:48 UTC
Review of attachment 367178 [details] [review]:

Ok, fix my comments before pushing, please.

::: backend/comics/comics-document.c
@@ +90,3 @@
+	if (basename == NULL) {
+		g_debug ("Filename '%s' doesn't have a basename?", name);
+		return FALSE;

return ret.

@@ +93,3 @@
+	}
+
+	ret = (strncmp (basename, APPLE_DOUBLE_PREFIX, strlen (APPLE_DOUBLE_PREFIX)) == 0);

g_str_has_prefix() is easier to read.

@@ +95,3 @@
+	ret = (strncmp (basename, APPLE_DOUBLE_PREFIX, strlen (APPLE_DOUBLE_PREFIX)) == 0);
+
+	return ret;

You should free basename before returning.

@@ +145,3 @@
 		name = ev_archive_get_entry_pathname (comics_document->archive);
+		/* Ignore https://en.wikipedia.org/wiki/AppleSingle_and_AppleDouble_formats */
+		if (is_apple_double (name)) {

I guess we could break files using ._ and not being the apple thing, but it's probably very unlikely to happen.
Comment 5 Bastien Nocera 2018-01-23 14:10:37 UTC
Created attachment 367314 [details] [review]
comics: Fix reading CBZ files created on macOS

macOS' builtin ZIP file format support will add AppleDouble files to the
archives in order to store information that would otherwise be stored in
extended attributes or resource forks, in a way that's unlikely to be
meddled with by applications that don't know how to handle this
metadata.

But when we store images in such a ZIP file, we'll end up with files
named "__MACOSX/dirname/._page0001.JPG" for example, which our current
code will interpret as being images, and thus pages in our comic.
They're not. As the AppleDouble files always have the "._" prefix,
ignore those.

See https://en.wikipedia.org/wiki/AppleSingle_and_AppleDouble_formats
Comment 6 Bastien Nocera 2018-01-23 16:51:43 UTC
Attachment 367314 [details] pushed as 7b4ff77 - comics: Fix reading CBZ files created on macOS