Bug 407537 - KArchive cannot read some files created with quazip
Summary: KArchive cannot read some files created with quazip
Status: CONFIRMED
Alias: None
Product: frameworks-karchive
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.58.0
Platform: Appimage Linux
: NOR critical
Target Milestone: ---
Assignee: David Faure
URL:
Keywords: regression, release_blocker
Depends on:
Blocks:
 
Reported: 2019-05-14 19:45 UTC by David REVOY
Modified: 2023-07-12 06:41 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David REVOY 2019-05-14 19:45:38 UTC
Hi,

This afternoon, I drew many things with krita-4.2.0-alpha-ca5aeb7-x86_64.appimage and saved many *.kra files. No issue in particular, exept for the last file here:

https://www.peppercarrot.com/extras/temp/2019-05-14_B_Gitlab.kra

- Dolphin can't generate a thumbnail for it, while I never had a problem with other kra.
- Nomacs (my viewer) can't preview the *.kra, while I never had a problem with other kra too.
- Krita 4.1x can't read it (invalid file), while ok for other kra...
- I can open it in 4.2x; but when I "save as" it does the same type of file each time.

So, I guess something is wrong with this *.kra file. Two paint layers, one group; nothing complex. I checked with Ark (unzip app), it has thumbnail, mergedimage.png. I can't figure why it is not a standard *.kra file. (Note: zip64 unchecked in *.kra preferences.) Thanks for the help!
Comment 1 Halla Rempt 2019-05-14 20:05:53 UTC
Hi Deevad,

I can confirm the issue. I will take a look into it tomorrow morning.
Comment 2 Halla Rempt 2019-05-15 08:40:04 UTC
* Ark can open the zip file: ark doesn't use karchive
* unzip can open the zip file and zip can zip it up so 4.1.7 can open it
* The problem is not that the file is in 64 bits mode
Comment 3 Halla Rempt 2019-05-15 10:04:58 UTC
kzip says: "Invalid ZIP file. Unrecognized header at offset 9476582" I think that an unrecognized header should not be a reason for failure, but I also wonder why master currently gives this error while I've been swapping 4.1 and master for tests all the time :-(
Comment 4 Halla Rempt 2019-05-16 09:32:20 UTC
Git commit 2ce21f054b903a84e11f9300cea2e2eec24982a6 by Boudewijn Rempt.
Committed on 16/05/2019 at 09:32.
Pushed by rempt into branch 'master'.

Add a legacy zip store that uses KArchive

KArchive's KZip cannot read all files that Quazip saves. This is
a bug in KArchive, but it breaks older versions of krita that
cannot load some files saved in 4.2 anymore. So, only use quazip
if 64 bits saving is enabled.

M  +1    -0    CMakeLists.txt
M  +2    -0    libs/store/CMakeLists.txt
A  +272  -0    libs/store/KoLegacyZipStore.cpp     [License: LGPL (v2+)]
A  +73   -0    libs/store/KoLegacyZipStore.h     [License: LGPL (v2+)]
M  +28   -2    libs/store/KoStore.cpp
M  +2    -0    libs/store/KoStore_p.h

https://invent.kde.org/kde/krita/commit/2ce21f054b903a84e11f9300cea2e2eec24982a6
Comment 5 Halla Rempt 2019-05-16 09:34:19 UTC
The file linked to in the report can be read with most zip tools, but not kzip. I think that this is a bug in kzip's zip implementation.
Comment 6 Halla Rempt 2019-05-16 09:44:24 UTC
Git commit e752d278e48b984f80286c9d0016c69b17d522d4 by Boudewijn Rempt.
Committed on 16/05/2019 at 09:44.
Pushed by rempt into branch 'krita/4.2'.

Add a legacy zip store that uses KArchive

KArchive's KZip cannot read all files that Quazip saves. This is
a bug in KArchive, but it breaks older versions of krita that
cannot load some files saved in 4.2 anymore. So, only use quazip
if 64 bits saving is enabled.

M  +1    -0    CMakeLists.txt
M  +2    -0    libs/store/CMakeLists.txt
A  +272  -0    libs/store/KoLegacyZipStore.cpp     [License: LGPL (v2+)]
A  +73   -0    libs/store/KoLegacyZipStore.h     [License: LGPL (v2+)]
M  +28   -2    libs/store/KoStore.cpp
M  +2    -0    libs/store/KoStore_p.h

https://invent.kde.org/kde/krita/commit/e752d278e48b984f80286c9d0016c69b17d522d4
Comment 7 David REVOY 2019-05-16 12:41:23 UTC
I built the fix and I confirm it is fixed. I could 'save as' the two problematics *.kra with git~master and they immediately recovered a preview thumbnail in Dolphin and are now readable by my image viewer. Thank you Boud!
Comment 8 Halla Rempt 2019-05-17 09:43:58 UTC
Git commit 4cb990274f8664d4eb3311af7755c8ff6065150c by Boudewijn Rempt.
Committed on 17/05/2019 at 09:40.
Pushed by rempt into branch 'master'.

Add a legacy zip store for writing backwards-compatible kra files

Use the Quazip store for reading and writing 64 bits zip files,
the Legacy store for writing 32 bits zip files. It's still not
ideal, having two zip implementations (and a third one hidden
inside Qt), but this gives maximal compatibility. Vectors and
colorize masks load again as well.
Related: bug 407601, bug 407630

M  +1    -0    CMakeLists.txt
M  +2    -0    libs/store/CMakeLists.txt
A  +272  -0    libs/store/KoLegacyZipStore.cpp     [License: LGPL (v2+)]
A  +73   -0    libs/store/KoLegacyZipStore.h     [License: LGPL (v2+)]
M  +27   -2    libs/store/KoStore.cpp
M  +2    -0    libs/store/KoStore_p.h

https://invent.kde.org/kde/krita/commit/4cb990274f8664d4eb3311af7755c8ff6065150c
Comment 9 Halla Rempt 2019-05-18 06:43:57 UTC
Git commit 77d87639051c2115aa516897cbb094cc4d8bbb19 by Boudewijn Rempt.
Committed on 18/05/2019 at 06:43.
Pushed by rempt into branch 'krita/4.2'.

Add a legacy zip store for writing backwards-compatible kra files

Use the Quazip store for reading and writing 64 bits zip files,
the Legacy store for writing 32 bits zip files. It's still not
ideal, having two zip implementations (and a third one hidden
inside Qt), but this gives maximal compatibility. Vectors and
colorize masks load again as well.
Related: bug 407601, bug 407630

M  +1    -0    CMakeLists.txt
M  +2    -0    libs/store/CMakeLists.txt
A  +272  -0    libs/store/KoLegacyZipStore.cpp     [License: LGPL (v2+)]
A  +73   -0    libs/store/KoLegacyZipStore.h     [License: LGPL (v2+)]
M  +27   -2    libs/store/KoStore.cpp
M  +2    -0    libs/store/KoStore_p.h

https://invent.kde.org/kde/krita/commit/77d87639051c2115aa516897cbb094cc4d8bbb19
Comment 10 Martin Sandsmark 2020-05-25 15:59:12 UTC
Looked at the attached file with a hex editor.

I think the problem is that quazip writes weird data_descriptor sizes (gpf bit 8 is set so we have to guess the next header, and seekToNextHeaderToken ends up 12 bytes after where it should be, which is coincidentally the size of the data descriptor).

I guess the quazip people misunderstood the "optional" part in the spec (you either write the whole data descriptor or you don't, you don't just write the signature). Or I'm reading something wrong.
Comment 11 qusai 2023-07-12 06:41:06 UTC
gog