Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Image Open"/"Image View" does not work with special character in filename #4377

Closed
mc-butler opened this issue Jun 18, 2022 · 14 comments
Closed
Assignees
Labels
area: core Issues not related to a specific subsystem prio: low Minor problem or easily worked around ver: 4.8.28 Reproducible in version 4.8.28
Milestone

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/4377
Reporter ro-ee (alexander@….it)
Keywords image, open, view, special characters

If I have an image file with either a special character (≥ U+0080) in it, for example German umlauts, or special punctuation (’, “, », …) in it, or in the path of it, it won’t be recognized as image, and pressing Enter (to open) or F3 to view won’t work.

"Image view" (F3) on the file then shows the hex view of the file instead of the image info usually displayed with images.

It works with video files though, so this seems limited to the image file detection.

@mc-butler
Copy link
Author

Changed by ro-ee (alexander@….it) on Jun 18, 2022 at 17:31 UTC (comment 1)

After reading the text, I would like to add that of course the file name (or the path) is meant when I wrote 'with a special character in it', not the content of the files (of course).

so: create an image file with the name "testö.jpg" or put an image file in a folder named "testö", MC won’t be able to open it with Enter or View the file info with F3.

It will work with an mp4 file, though (and call your video player of choice), so "testö.mp4" or a folder named "testö" will work.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jun 18, 2022 at 18:11 UTC (comment 2)

Works for me.

Please temporarily remove ~/.config/mc/mc.ext and try again.

@mc-butler
Copy link
Author

Changed by ro-ee (alexander@….it) on Jun 18, 2022 at 18:35 UTC (comment 3)

Removing mc.ext or even completely removing .config/mc: still the same (also if I use another account on the same computer).

I am not able to find a global mc.ext that might be used instead.

My locale is
LANG="en_US.TF-8"
LC_CTYPE="en_US.UTF-8"

I added debug code to the /usr/libexec/mc/ext.d/image.sh to see if it even gets called, which is not the case (I have since reverted back these changes, to make sure this isn’t the source of further issues)

Is there a way to print out the mc.ext which is currently in use? (i.e. the built-in one)?

One add: this is the same for jpg, gif and png files (I’m only writing this because in the current mc.ext (which I have since renamed), JPEG is the only one which adds one additional View command, the PNG, GIF, ... files directly refer to the Include=image part.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jun 19, 2022 at 4:48 UTC (comment 3.4)

Replying to ro-ee:

I am not able to find a global mc.ext that might be used instead.

mc -F shows all directories used by mc.

My locale is
LANG="en_US.TF-8"
LC_CTYPE="en_US.UTF-8"

I added debug code to the /usr/libexec/mc/ext.d/image.sh to see if it even gets called, which is not the case (I have since reverted back these changes, to make sure this isn’t the source of further issues)

Is there a way to print out the mc.ext which is currently in use? (i.e. the built-in one)?

Usually, global mc.ext is /etc/mc/mc.ext. There is no any built-in one.

@mc-butler
Copy link
Author

Changed by dimich (@dimich-dmb) on Jun 25, 2022 at 2:50 UTC (comment 5)

"type" key in mc.ext doesn't work properly with non-ascii file names because file utility replaces non-ascii characters in output to its octal codes and distorts a name. Midnight Commander then compares this name to supplied name (in ext.c:regex_check_type()) and calculates content_shift incorrectly, thus mc_search_new() fails.
It would be good to use --brief option of file if it's supported on all platforms.
Also --mime option could make output parsing much easier and deterministic.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jun 25, 2022 at 6:56 UTC (comment 5.6)

Thank you for the analyzing.

Replying to dimich:

"type" key in mc.ext doesn't work properly with non-ascii file names because file utility replaces non-ascii characters in output to its octal codes and distorts a name.

Perhaps it depends on file version:

$ file testö.jpg
testö.jpg: JPEG image data, JFIF standard 1.02
$ file -v
file-4.26
magic file from /etc/magic:/usr/share/file/magic

It would be good to use --brief option of file if it's supported on all platforms.

It's a good idea.

Also --mime option could make output parsing much easier and deterministic.

Cannot see any the useful info:

testö.jpg, 1: Warning: offset `����' invalid
testö.jpg, 1: Warning: type `����' invalid
testö.jpg, 2: Warning: offset `��Mh�b���^���E\XJH6=�\W>_��^�9*6\H������9����\� ��4      Ο' invalid
testö.jpg, 2: Warning: type `��Mh�b���^���E\XJH6=�\W>_��^�9*6\H������9����\� ��4  [���Ο' invalid
�Hcy�����b 3: Warning: offset `p��X����^���T�hc��Ҹ�0E_��c���eI.�������k         [���5�
          �;Ԍ&L���އ �B4mc��7��' invalid
�Hcy�����b 3: Warning: type `p��X����^���T�hc��Ҹ�0E_��c���eI.�������k
          �;Ԍ&L���އ �B4mc��7��' invalid
testö.jpg, 4: Warning: offset `��iчY4r[`GH�Oή��"4�U���ƌ�E

Perhaps it depends on file version too.

@mc-butler
Copy link
Author

Changed by ro-ee (alexander@….it) on Jun 25, 2022 at 7:38 UTC (comment 7)

I have file version 5.42

alex@horus:~> file -v
file-5.42
magic file from /etc/magic:/usr/share/misc/magic
seccomp support included

and get

alex@horus:~> file testö.jpg 
test\303\266.jp: JPEG image data, JFIF standard 1.01, resolution (DPCM), density 118x118, segment length 16, progressive, precision 8, 1706x1132, components 3

notice that even the 'g' is missing in the filename.

Still, what I don’t understand that this does not happen with videos? or isn’t 'file' not invoked in all cases, and .mp4 files are detected by other means?

using the --raw/-r parameter on 'file' will print the correct character (or leave the character as-is), but it still gets shortened by one character:

alex@horus:~> file testö.jpg -r
testö.jp: JPEG image data, JFIF standard 1.01, resolution (DPCM), density 118x118, segment length 16, progressive, precision 8, 1706x1132, components 3

@mc-butler
Copy link
Author

Changed by ro-ee (alexander@….it) on Jun 25, 2022 at 10:38 UTC (comment 8)

From a bug report in opensuse forums, where I first reported this,

https://forums.opensuse.org/showthread.php/571604-(%E2%89%A5-0x80)?p=3137435#post3137435

it looks like a patch made to 'file' on May 28th is to blame. There is something wrong with the patch (even in -raw mde, because of the shortening of the file name), but I think going with the -b option is the better route to take.

@mc-butler
Copy link
Author

Changed by dimich (@dimich-dmb) on Jun 25, 2022 at 15:39 UTC (comment 6.9)

Replying to andrew_b:

Perhaps it depends on file version

Filename conversion was introduced recently by this commit: file/file@f448f3e and it is already in file-5.42.

Also --mime option could make output parsing much easier and deterministic.

Cannot see any the useful info

$ file --brief --mime-type /tmp/testö.jpg 
image/jpeg
$
$ file -v
file-5.42
magic file from /usr/share/file/misc/magic
seccomp support included

Replying to ro-ee:

Still, what I don’t understand that this does not happen with videos? or isn’t 'file' not invoked in all cases, and .mp4 files are detected by other means?

In default mc.ext videos are detected by filenames with "shell/regex" keys, not by "type".

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jun 26, 2022 at 17:05 UTC (comment 10)

  • Owner set to andrew_b
  • Status changed from new to accepted

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jun 26, 2022 at 17:07 UTC (comment 11)

  • Milestone changed from Future Releases to 4.8.29
  • Branch state changed from no branch to on review

Branch: 4377_file_b
Initial [0bb9c04]

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 3, 2022 at 12:46 UTC (comment 12)

  • Branch state changed from on review to approved
  • Votes set to andrew_b

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 3, 2022 at 12:49 UTC (comment 13)

  • Branch state changed from approved to merged
  • Resolution set to fixed
  • Votes changed from andrew_b to committed-master
  • Status changed from accepted to testing

Merged to master: [ab63cd2].

git log --pretty=oneline 6c4520874..ab63cd2a9

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Jul 3, 2022 at 12:50 UTC (comment 14)

  • Status changed from testing to closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues not related to a specific subsystem prio: low Minor problem or easily worked around ver: 4.8.28 Reproducible in version 4.8.28
Development

No branches or pull requests

2 participants