[Bug 1201122] New: MidnightCommander no longer performs open or view action on files with multi-byte characters in the filename (at least snapshot 20220702)
http://bugzilla.opensuse.org/show_bug.cgi?id=1201122 Bug ID: 1201122 Summary: MidnightCommander no longer performs open or view action on files with multi-byte characters in the filename (at least snapshot 20220702) Classification: openSUSE Product: openSUSE Tumbleweed Version: Current Hardware: x86-64 OS: openSUSE Tumbleweed Status: NEW Severity: Normal Priority: P5 - None Component: Other Assignee: screening-team-bugs@suse.de Reporter: d_werner@gmx.net QA Contact: qa-bugs@suse.de Found By: --- Blocker: --- mc has an extension file. default: /etc/mc/mc.ext in this file actions (open, view) to perform for specific file types are defined. E.g. for image files a script /usr/libexec/mc/ext.d/image.sh open xcf I noticed with snapshot 20220702 that mc no longer opens files which contain multi-byte characters in the filename, e.g. test���.jpg. Files without multi-byte characters, e.g. test.jpg, can still be opened as before. This problem was introduced between snapshot 20220613 and 20220702. In standard configuration images, e.g. jpeg, are opened using /usr/libexec/mc/ext.d/image.sh. I made a small adaptation to this file and put it in ~/.local/share/mc/ext.d and adapted the path in the ~/.config/mc/mc.ext to use this one instead. The modification is just to record the opening action and the file name: user@factory:~/.local/share/mc/ext.d$ diff /usr/libexec/mc/ext.d/image.sh ~/.local/share/mc/ext.d/image.sh 9c9,11 < [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="xdg-open" ---
echo "before action $action filetyte $filetype MC_XDG_OPEN ${MC_XDG_OPEN} ${MC_EXT_FILENAME}" >> ~/mc_image.sh_open.txt [ -n "${MC_XDG_OPEN}" ] || MC_XDG_OPEN="_xdg_open" echo "after action $action filetyte $filetype MC_XDG_OPEN ${MC_XDG_OPEN} ${MC_EXT_FILENAME}" >> ~/mc_image.sh_open.txt
Trying to open the 2 files {cover.jpg,cover���.jpg} (pressing enter when the file is highlighted in the mc panel) results in the entries as expected in snapshot 20220630 and both file open successfully. In snapshot 20220702 only the file without multi-byte character appears in the log output, no call of the script happens for the filename with the multi-byte character in the filename: cat mc_image.sh_open.txt before action open filetyte ALL_FORMATS MC_XDG_OPEN /home/user/cover.jpg after action open filetyte ALL_FORMATS MC_XDG_OPEN _xdg_open /home/user/cover.jpg before action open filetyte ALL_FORMATS MC_XDG_OPEN /home/user/cover���.jpg after action open filetyte ALL_FORMATS MC_XDG_OPEN _xdg_open /home/user/cover���.jpg ---------------^^^ 0613 before action open filetyte ALL_FORMATS MC_XDG_OPEN /home/user/cover.jpg after action open filetyte ALL_FORMATS MC_XDG_OPEN _xdg_open /home/user/cover.jpg ---------------^^^ 0702 Maybe the bug is not in mc itself but in some used library (like f bug 1200688) or a bug in mc is uncovered by FORTIFY_SOURCE=3. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1201122 http://bugzilla.opensuse.org/show_bug.cgi?id=1201122#c1 --- Comment #1 from Dirk Weber <d_werner@gmx.net> --- according to ltrace on mc's PID it executes "file" in order to determine the file type, and at this point the filename is correct ltrace -fi -p 4953 -s 256 -o broken3.txt ... 6142 [0x55cbe7590aec] strcpy(0x55cbe87c0210, "file -z -S -L /home/user/test\342\202\254.jpg 2>/dev/null") = 0x55cbe87c0210 ... 4953 [0x5633f9a2d350] strchr("/home/user/test\\342\\202\\254.j: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 600 4953 [0x5633f9a2d360] strlen("/home/user/test\342\202\254.jpg") = 22 ... strange is that in the output of "file" the filename is not complete: 2 characters are missing. This can also be reproduced on the command line for files with multi-byte characters, but not for other even longer filenames: user@factory:~$ file test_longer_name.jpg test_longer_name.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 600x800, components 3 user@factory:~$ file test���.jpg test\342\202\254.j: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 600x800, components File names with more multi-byte characters are more truncated in the output of "file": user@factory:~$ file test������������.jpg test\342\202\254\342\202\254\342\202: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 600x800, components In the ltrace output of mc I do not see that mc uses the broken filename from file, therefore I would currently think that this is not the reason for the failure to open the file. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1201122 http://bugzilla.opensuse.org/show_bug.cgi?id=1201122#c2 --- Comment #2 from Dirk Weber <d_werner@gmx.net> --- There exists an upstream ticket for this issue: https://midnight-commander.org/ticket/4377 It also mentions the relation to the garbled filename in the output of "file" (the program) when the target filename contains special characters. And it contains a fix. -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1201122 http://bugzilla.opensuse.org/show_bug.cgi?id=1201122#c3 --- Comment #3 from Dirk Weber <d_werner@gmx.net> --- Small test script to prove that really the garbled output of "file" in case of files with multi-byte characters in the filename is the culprit. This script can also be used as a temporary workaround. create a file ~/bin/file with the content between "----" ---- #!/bin/bash NAME=$(/usr/bin/file -b "$@") echo "${BASH_ARGV[0]}: $NAME" ---- explanation: the bin directory of the user is in the path before /usr/bin - this can be verified by echo $PATH Therefore mc will then call this script instead of /usr/bin/file The script in turn calls /usr/bin/file but with the additional parameter "-b" which tells file (file --help): -b, --brief do not prepend filenames to output lines then the script creates the output as expected by mc-4.8.28-2.1.x86_6 by prepending the correct filename and a colon. Example: file -z -S -L /home/user/test���������.jpg /home/user/test���������.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 600x800, components 3 /usr/bin/file -z -S -L /home/user/test���������.jpg /home/user/test\342\202\254\342\202\254\342: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 600x800, components 3 In this way mc can again open files with multi-byte characters in the filename for which it uses the type keyword in the mc.ext. This also shows that the actual bug is in file-5.42-1.1.x86_64 -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1201122 Dirk Weber <d_werner@gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|MidnightCommander no longer |MidnightCommander no longer |performs open or view |performs open or view |action on files with |action on files with |multi-byte characters in |multi-byte characters in |the filename (at least |the filename for files |snapshot 20220702) |identified with "type" (at | |least snapshot 20220702) | |due to garbled output of | |the "file" command -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1201122 http://bugzilla.opensuse.org/show_bug.cgi?id=1201122#c4 --- Comment #4 from Dirk Weber <d_werner@gmx.net> --- Created attachment 860092 --> http://bugzilla.opensuse.org/attachment.cgi?id=860092&action=edit put as ~/bin/file as workaround for garbled filename output of "file"-binary from file-5.42-1.1.x86_64 Note: this workaraound has to be removed when mc itself uses the "-b" or "--brief" arguments to call file! -- You are receiving this mail because: You are on the CC list for the bug.
http://bugzilla.opensuse.org/show_bug.cgi?id=1201122 http://bugzilla.opensuse.org/show_bug.cgi?id=1201122#c5 --- Comment #5 from Dirk Weber <d_werner@gmx.net> --- bug 1201350 opened for the file package which is the origin for the problem reported in this bug. -- You are receiving this mail because: You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@suse.com