From 14083377d1877a6a766b0a33e3f5c5db1c984b0e Mon Sep 17 00:00:00 2001 From: Patrick Farwick <9168045+MinecraftPlaye@users.noreply.github.com> Date: Sat, 22 Jan 2022 01:00:03 +0000 Subject: [PATCH 1/4] Only use comic pages for internal calculations A comic book archive stores pages as images, but can store other information like metadata within the file, too. This change uses only the image based files as pages and ignores other files. --- src/plugins/comicsPlayer/plugin.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/comicsPlayer/plugin.js b/src/plugins/comicsPlayer/plugin.js index 3f6f844e3e..6f53d28786 100644 --- a/src/plugins/comicsPlayer/plugin.js +++ b/src/plugins/comicsPlayer/plugin.js @@ -259,7 +259,15 @@ class ArchiveSource { this.raw = await this.archive.getFilesArray(); await this.archive.extractFiles(); - const files = await this.archive.getFilesArray(); + // the comic book archive supports any kind of image format as it's just a zip archive + const supportedFormats = ['jpg', 'png', 'avif', 'gif', 'bmp', 'dib', 'tiff', 'tif']; + + let files = await this.archive.getFilesArray(); + files = files.filter((file) => { + const name = file.file.name; + const index = name.lastIndexOf('.'); + return supportedFormats.includes(name.substr(index + 1)); + }); files.sort((a, b) => { if (a.file.name < b.file.name) { return -1; From 4f770f26ce117e05fb18d45704a8c9011047bc0b Mon Sep 17 00:00:00 2001 From: Patrick Farwick <9168045+MinecraftPlaye@users.noreply.github.com> Date: Sat, 22 Jan 2022 21:17:57 +0000 Subject: [PATCH 2/4] Ignore files which do not have a file extension --- src/plugins/comicsPlayer/plugin.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/comicsPlayer/plugin.js b/src/plugins/comicsPlayer/plugin.js index 6f53d28786..139704f69f 100644 --- a/src/plugins/comicsPlayer/plugin.js +++ b/src/plugins/comicsPlayer/plugin.js @@ -241,6 +241,9 @@ export class ComicsPlayer { } } +// the comic book archive supports any kind of image format as it's just a zip archive +const supportedFormats = ['jpg', 'png', 'avif', 'gif', 'bmp', 'dib', 'tiff', 'tif']; + class ArchiveSource { constructor(url) { this.url = url; @@ -259,14 +262,11 @@ class ArchiveSource { this.raw = await this.archive.getFilesArray(); await this.archive.extractFiles(); - // the comic book archive supports any kind of image format as it's just a zip archive - const supportedFormats = ['jpg', 'png', 'avif', 'gif', 'bmp', 'dib', 'tiff', 'tif']; - let files = await this.archive.getFilesArray(); files = files.filter((file) => { const name = file.file.name; const index = name.lastIndexOf('.'); - return supportedFormats.includes(name.substr(index + 1)); + return index !== 1 && supportedFormats.includes(name.slice(index + 1)); }); files.sort((a, b) => { if (a.file.name < b.file.name) { From 43077bd25956daaf16ecb387a97c79a0c280dd82 Mon Sep 17 00:00:00 2001 From: Patrick Farwick <9168045+MinecraftPlaye@users.noreply.github.com> Date: Wed, 9 Feb 2022 15:18:41 +0000 Subject: [PATCH 3/4] Add all file extensions for jpeg images --- src/plugins/comicsPlayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/comicsPlayer/plugin.js b/src/plugins/comicsPlayer/plugin.js index 139704f69f..d8abaa226f 100644 --- a/src/plugins/comicsPlayer/plugin.js +++ b/src/plugins/comicsPlayer/plugin.js @@ -242,7 +242,7 @@ export class ComicsPlayer { } // the comic book archive supports any kind of image format as it's just a zip archive -const supportedFormats = ['jpg', 'png', 'avif', 'gif', 'bmp', 'dib', 'tiff', 'tif']; +const supportedFormats = ['jpg', 'jpeg', 'jpe', 'jif', 'jfif', 'jfi', 'png', 'avif', 'gif', 'bmp', 'dib', 'tiff', 'tif']; class ArchiveSource { constructor(url) { From e1889d9151fca7352ba208c79849936f5100d5f6 Mon Sep 17 00:00:00 2001 From: Patrick Farwick <9168045+MinecraftPlaye@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:31:28 +0000 Subject: [PATCH 4/4] Ignore files without a file extension Files which do not have a file extension are most likely not an image and should not be used as a page of a comic book. --- src/plugins/comicsPlayer/plugin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/comicsPlayer/plugin.js b/src/plugins/comicsPlayer/plugin.js index d8abaa226f..69882b65b2 100644 --- a/src/plugins/comicsPlayer/plugin.js +++ b/src/plugins/comicsPlayer/plugin.js @@ -263,10 +263,12 @@ class ArchiveSource { await this.archive.extractFiles(); let files = await this.archive.getFilesArray(); + + // metadata files and files without a file extension should not be considered as a page files = files.filter((file) => { const name = file.file.name; const index = name.lastIndexOf('.'); - return index !== 1 && supportedFormats.includes(name.slice(index + 1)); + return index !== -1 && supportedFormats.includes(name.slice(index + 1)); }); files.sort((a, b) => { if (a.file.name < b.file.name) {