Skip to content

Conversation

@gerardbosch
Copy link

Proposed changes

Fix/add support for JAR/WAR files with shell associations.

The file command apparently behaves inconsistently between Linux distributions—that prevents opening JAR files (which are just ZIP files with metadata) in Manjaro/Arch Linux within Midnight Commander; and inspecting/editing source code within those compressed files.

WAR files were missing (that was reported here): https://bugs.launchpad.net/mc/+bug/2062968/comments/16 - this PR adds support for them via extension match.

Checklist

👉 Our coding style can be found here: https://midnight-commander.org/coding-style/ 👈

  • I have referenced the issue(s) resolved by this PR (if any)
  • I have signed-off my contribution with git commit --amend -s
  • Lint and unit tests pass locally with my changes (make indent && make check)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

@github-actions github-actions bot added this to the Future Releases milestone Nov 6, 2025
@github-actions github-actions bot added needs triage Needs triage by maintainers prio: medium Has the potential to affect progress labels Nov 6, 2025
Copy link
Contributor

@ossilator ossilator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i find the whole approach mildly fishy; see the inline comment.


the lines in the commit message are a bit long.


[jar]
[jar-by-type]
Type=\\(Java (Jar file|archive) data \\((zip|JAR)\\)\\)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on the addition of .war handling below, it would seem logical to add it here as well, or does no file variant recognize these as anything other than a regular zip archive?

actually, what are the files recognized as? you're not saying in the commit message.

the idea behind using content based detection is to catch files with non-standard extensions (for .jars, that may be modules in some applications). falling back to extension based detection is basically admitting defeat ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, wars are nothing other than jars, only meant to be uploaded to the application servers, so file output would be the same for both. In this sense, they have always been implicitly supported, or at least they should have been.

Given a number of recent posts to #4862 tickets, however, I think indeed it's time to admit defeat and add extension-based fallbacks. It seems that the problem is that even though we are now correctly matching on the file output, the utility itself is unreliable and often enough doesn't detect the correct type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.wars contain additional metadata, so they could be detected separately.

i'd really like to see the exact status quo documented (in the commit message), so it's obvious what is being worked around and that this is the only reasonable way to do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.wars contain additional metadata, so they could be detected separately.

Maybe, but the file tool doesn't (currently) include any such provisions. I did search the source for both "jar" and "war".

i'd really like to see the exact status quo documented (in the commit message), so it's obvious what is being worked around and that this is the only reasonable way to do it.

I've updated the commit message. I think it's good enough now.

@azazar
Copy link

azazar commented Jan 19, 2026

Why not identify files by content when extension associations search fails? Like Far Manager does.

@zyv
Copy link
Member

zyv commented Jan 20, 2026

Why not identify files by content when extension associations search fails? Like Far Manager does.

This PR does exactly the opposite: identify by extension if content search fails (which apparently happens for a surprisingly high number of users even after all the fixes that we've made to it).

@zyv zyv changed the title fix(misc/file-handler): Handling to open JAR and WAR files Add extension-based fallbacks for handling JAR and WAR files to mc.ext Jan 31, 2026
@zyv zyv added area: vfs Virtual File System support and removed needs triage Needs triage by maintainers labels Jan 31, 2026
@zyv zyv force-pushed the fix/jar-handler branch from 083f690 to 76c56d7 Compare January 31, 2026 16:41
@zyv zyv modified the milestones: Future Releases, 4.9.0 Jan 31, 2026
@zyv zyv requested review from mc-worker and ossilator January 31, 2026 16:45
@zyv zyv changed the title Add extension-based fallbacks for handling JAR and WAR files to mc.ext Ticket #4861: add extension-based fallbacks for handling JAR and WAR files to mc.ext Jan 31, 2026

[jar]
[jar-by-type]
Type=\\(Java (Jar file|archive) data \\((zip|JAR)\\)\\)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.wars contain additional metadata, so they could be detected separately.

i'd really like to see the exact status quo documented (in the commit message), so it's obvious what is being worked around and that this is the only reasonable way to do it.

@zyv zyv force-pushed the fix/jar-handler branch from 76c56d7 to 69aa6be Compare February 1, 2026 13:26
@zyv
Copy link
Member

zyv commented Feb 1, 2026

/rebase

…and WAR files to mc.ext

Detection for JAR files in the `file` command apparently is flaky and behaves
inconsistently between Linux distributions.

On top of that, as of yet, there aren't any provisions for detecting WAR
files, so those can only be supported by an extension match at this point.

Signed-off-by: Gerard Bosch <30733556+gerardbosch@users.noreply.github.com>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
@gerardbosch
Copy link
Author

Hello! Sorry I got very busy with other topics and never found the time to get back to this. Thanks to move it forward 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: vfs Virtual File System support prio: medium Has the potential to affect progress

Development

Successfully merging this pull request may close these issues.

Cannot open .jar files: file output doesn't match & missing [jar-by-shell]

4 participants