GNOME Bugzilla – Bug 792754
comics: Fix reading CBZ files created on macOS
Last modified: 2018-01-23 16:51:47 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.
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.
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
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.
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
Attachment 367314 [details] pushed as 7b4ff77 - comics: Fix reading CBZ files created on macOS