Ticket #4368 (closed defect: fixed)

Opened 8 months ago

Last modified 2 months ago

Problems viewing zip files

Reported by: blacktav Owned by:
Priority: major Milestone: 4.8.29
Component: mc-core Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

I am experiencing strange behaviour with some zip files

a zip file built locally using zip 3.0

In mc this behaves as expected: view opens a file list, open permits browsing the contents of the zip file (ie. using extfs uzip)

File type reported as

Kerryvanning.zip: Zip archive data, at least v1.0 to extract, compression method=store

a download from Google's photo tool

view::
mc throws an error
identify: no decode delegate for the image format `ZIP' @ error/constiture.c/ReadImage/737.

open::
mc opens the file for browsing but in an external app triggering a call through xdg

File type is reported as:
Photos-2016.zip: Zip archive data, at least v2.0 to extract, compression method=deflate

mc.ext

There are 2 definitions for zip files: one on the file extension shell/i/.zip, the other by type type/\(Zip archive although they both have the same commands and it does not matter which is triggered - behaviour is identical

ie. I removed one or other or both

Conclusion & workaround

Given the view error message, it looks like the file is being interpreted as an image and handed off as appropriate

Commenting out the image type handlers in mc.ext (the JPG one in particular) and behaviour reverts to normal zip-file handling.

workaround::
Since the image types appear before compressed file detection, moving image detection to later in the mc.ext file produces normal behaviour

There must be some issue with the built-in file-type detection (the tested file does contain JPG images)


Home directory: /home/drew
Profile root directory: /home/drew

[System data]
    Config directory: /etc/mc/
    Data directory:   /usr/share/mc/
    File extension handlers: /usr/lib/mc/ext.d/
    VFS plugins and scripts: /usr/lib/mc/
	extfs.d:        /usr/lib/mc/extfs.d/
	fish:           /usr/lib/mc/fish/

[User data]
    Config directory: /home/drew/.config/mc/
    Data directory:   /home/drew/.local/share/mc/
	skins:          /home/drew/.local/share/mc/skins/
	extfs.d:        /home/drew/.local/share/mc/extfs.d/
	fish:           /home/drew/.local/share/mc/fish/
	mcedit macros:  /home/drew/.local/share/mc/mc.macros
	mcedit external macros: /home/drew/.local/share/mc/mcedit/macros.d/macro.*
    Cache directory:  /home/drew/.cache/mc/
 '--prefix=/usr' '--libexecdir=/usr/lib' '--sysconfdir=/etc' '--enable-vfs-smb' '--with-screen=slang' '--with-x' 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -flto=auto' 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto'

Attachments

mc-test-fail.zip (33.5 KB) - added by blacktav 8 months ago.
Contains jpg images - fails to open
mc-test-pass.zip (16.4 KB) - added by blacktav 8 months ago.
Contains random stuff from mc source code - opens fine in mc

Change History

comment:1 Changed 8 months ago by andrew_b

  • Status changed from new to closed
  • Resolution set to invalid
  • Milestone Future Releases deleted

There was some changes in mc.ext file. You should sync your user's mc.ext with system-wide one.

See also ticket:4180#comment:22.

comment:2 Changed 8 months ago by blacktav

  • Status changed from closed to reopened
  • Resolution invalid deleted

Sorry, but the fix mentioned in ticket:4180#comment:22 has not been actioned - misc/mc.ext.in does not include such a change in the current source tree i.e. "### Images ###" still precedes compressed file definitions

Builds for 4.8.28 continue to generate a broken mc.ext file

Perhaps a recent change reverted a fix? Or have I missed something?

comment:3 Changed 8 months ago by andrew_b

Do you have ~/.config/mc/mc.ext? If yes, are ~/.config/mc/mc.ext and /etc/mc/mc.ext different?

comment:4 Changed 8 months ago by blacktav

No - I have no local mc.ext

I have edited my system mc.ext so that '## Images ##' follows compressed files. This opens zip files for browsing as expected

If I build mc 4.8.28 from a source download and copy the mc.ext created into my local config i.e. to .config/mc and restart mc - then opening zip files fail

comment:5 Changed 8 months ago by blacktav

Please note that I am using a download from Google Photo i.e. the zip file contains several jpg files
Hold on and I will upload a test file for you...

Changed 8 months ago by blacktav

Contains jpg images - fails to open

Changed 8 months ago by blacktav

Contains random stuff from mc source code - opens fine in mc

comment:6 Changed 8 months ago by andrew_b

This is the result of #4128 [8857423e4ebb770b6f0ea3103abf5d35c85fcbe8]. The file utility with -z option is used to determinate file type:

$ file -L mc-test-fail.zip 
mc-test-fail.zip: Zip archive data, at least v2.0 to extract
$ file -z -L mc-test-fail.zip 
mc-test-fail.zip: JPEG image data, JFIF standard 1.01 (Zip archive data, at least v2.0 to extract)

After #4128 we made several iterations to fix introduced problems:
#4180 [7881ed2fda7390d3821abd6864d0097fc818f0ac]
#4180 [c3848a689c0323ba7958e2943878fe831369af01]
#4223 [0e023f0dd9ca18a2bab8df6d25ed3c7d9dcbd2d1]
#4273 [78f8f97fed3a478e20e4a78297f73b0f84f697a9]
#4272 [53b1bb63acaa93a1c41a22a5c6ac1204b6140aed]

The new attempt is yet another change of rules order: first view at file names (regex/ and shell/), than file types detected by file -z -L (type/).

comment:7 Changed 8 months ago by ossi

first view at file names (regex/ and shell/), than file types detected by file -z -L (type/).

not necessarily.

first one needs to match things that are technically archives, but aren't supposed to be treated as such (*), e.g. various ODF files, and compressed man pages.
then one can match "regular" archives.
this can all be done by type, though matching by patterns is of course more efficient (but requires them to be truly unique, and no weird alternative file names being used).
then match everything else, which will be never reached if the file is inside an archive.

(*) they can be still entered with ctrl-pgdn if one really wants to.

note also #4141, which is somewhat complementary.

comment:8 follow-up: ↓ 9 Changed 8 months ago by blacktav

Why do you want open a zip file containing jpg files when trying to determine if a file is a jpg?
Are you expecting to be able to render all jpgs within a zip container?

Anyways the file "-z" switch may be problematic: when used against some files (the files I am having a problem with), it crashes

I can provide a sample file but it is too large (14389K) for this tracker - here is a link

# file --version
file-5.41
magic file from /usr/share/file/misc/magic
seccomp support included

# file Photos-2021.zip 
Photos-2021.zip: Zip archive data, at least v2.0 to extract, compression method=deflate

# file -z Photos-2021.zip 
Photos-2021.zip: Bad system call
Last edited 8 months ago by blacktav (previous) (diff)

comment:9 in reply to: ↑ 8 ; follow-up: ↓ 10 Changed 8 months ago by andrew_b

Replying to blacktav:

Anyways the file "-z" switch may be problematic: when used against some files (the files I am having a problem with), it crashes

This is known issue and it was fixed in [1ed638d66cf803f69ac12ee80a72d217f2146e43].

comment:10 in reply to: ↑ 9 Changed 8 months ago by blacktav

Replying to andrew_b:

Replying to blacktav:

Anyways the file "-z" switch may be problematic: when used against some files (the files I am having a problem with), it crashes

This is known issue and it was fixed in [1ed638d66cf803f69ac12ee80a72d217f2146e43].

Ahhh - Good call!

comment:11 follow-up: ↓ 12 Changed 8 months ago by ossi

Why do you want open a zip file containing jpg files when trying to determine if a file is a jpg?

nobody wants that per se. a hierarchical decision tree that uses file -z only in some branches would be better, but it would require more complicated infrastructure.

i actually find it kinda weird that file -z describes the contents of multi-file archives without specific semantics. but it is what it is.

comment:12 in reply to: ↑ 11 Changed 8 months ago by blacktav

Replying to ossi:

Why do you want open a zip file containing jpg files when trying to determine if a file is a jpg?

nobody wants that per se. a hierarchical decision tree that uses file -z only in some branches would be better, but it would require more complicated infrastructure.

i actually find it kinda weird that file -z describes the contents of multi-file archives without specific semantics. but it is what it is.

Interesting!
Would a mime-type detector work in this case? i.e. would a mime-type be sufficiently granular for mc purposes?
I am rather surprised that there does not appear to be any such linux/gnu tool

comment:13 Changed 8 months ago by ossi

see discussion in #2118.

comment:14 Changed 5 months ago by andrew_b

Ticket #4390 has been marked as a duplicate of this ticket.

comment:15 Changed 4 months ago by ulno

As it still doesn't seem to be fixed upstream and to give others a chance to use the old mc behavior (just broke a 20 year old workflow for me), I added these lines to the beginning of ### Archives ### section in mc.ext (for me in Arch with either mc-git or mc 4.8.28 under /etc/mc/mc.ext - or of course just inside your home .config/mc):

regex/\.[zZ][iI][pP]$
	Open=%cd %p/uzip://
	View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip

comment:16 Changed 3 months ago by andrew_b

Ticket #4403 has been marked as a duplicate of this ticket.

comment:17 Changed 2 months ago by andrew_b

  • Status changed from reopened to closed
  • Resolution set to fixed
  • Milestone set to 4.8.29

I hope this is finally fixed in #4141.

Note: See TracTickets for help on using tickets.