Files whose names begin with a colon (:)(0x3A) or a tilde (~)(0x7E), or containing a quote (")(0x22) cannot be opened with the file-open dialog.
Steps to Reproduce:
1. Open Konsole and enter these commands:
echo "Hello World." > :
cp : :0
cp : \~
cp : \~0
cp : \"
kate \" &
2. Kate will have opened the file named ". Press Ctrl+W to close it, then Ctrl+O to get the "Open File" dialog. You should see 5 files in ~/newdir named as follows:
3. Try opening any of the five files.
When clicking on either the file named ~ or the file named :, the "Open File" dialog will switch to showing files in the user's home folder rather than opening the file.
When clicking on the file named ~0, the file name briefly flashes in the "File:" field, but the file does not open.
When clicking on the file named :0, the file name briefly flashes in the "File:" field, and the file does not open. In addition, the following error message is displayed:
kfilemodule(20501): couldn't create slave: "Unable to create io-slave:
klauncher said: Unknown protocol ''.
When clicking on the file named ", the name will be placed in the "Name:" field, but the file cannot be opened.
When clicking on the name or icon of any of the five files, the respective file should be opened.
Opening a file whose name has a tilde or colon in the middle or end of the name does not seem to be a problem. Files whose names have one or more quote characters anywhere in the name do not work. All other characters in 7-bit ASCII (except slash (/) and null (\0) of course) appear to be supported.
Files starting with a colon are used in various places on a normal Linux system, and thus should be supported. Examples include /var/lib/ucf/cache/* and /run/lightdm/root/* .
Files starting with a tilde are, perhaps, less common (tildes are frequently used at the end of file names), but there's no reason not to support them.
Files containing quotes may be inadvisable, but they're perfectly legitimate UNIX and ext4 file names.
Files beginning with a colon appear to present extra problems for various applications like kate or okteta, but these would appear to be separate bugs.
I can confirm this bug in 4.10.5.
I also tried it in git master but the behavior is different:
I created 3 files with the following names: '-test', ':test' and 'files "test"'.
- Starting a file name with a tile seams to work properly on master
- Starting a file name with a colon and trying to open it not only failed, but it created a dir named ":" and a file named ":test.desktop" in my home directory
- Trying to open the file 'file "test"' created a new file named only 'test' and opened that new file.
~ (tilde) is bug 317513
" (quotes) is bug 185433
Regarding the : (colon), this could be related to Qt resources or Windows path handling.
Using this bug to track just the colon issue, since we have other bugs for the other characters.
*** Bug 267371 has been marked as a duplicate of this bug. ***
*** Bug 312226 has been marked as a duplicate of this bug. ***
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/250
That MR only covers the kfilewidget case; for kate I'll open a separate report to track the issue.
I've opened bug 430216.
Git commit c5dbb7c5452f1af637540efdf09061765c0ffb2d by Ahmad Samir.
Committed on 12/12/2020 at 10:15.
Pushed by dfaure into branch 'master'.
KFileWidget: allow files that begin with a ':' to be selected
The issue was that a ':' at the beginning denotes a Qt Resource and in that
case QDir::isAbsolutePath() would return true. The bug is fixed by guarding
against that condition in slotOk().
Also guard other QDir::isAbsolutePath() usage the same way.
Since this logic will be used in various places use a helper function,
isAbsoluteLocalPath() (thanks to dfaure for coming up with that name),
Extend the unit tests.
M +15 -6 autotests/kfilewidgettest.cpp
M +5 -6 src/filewidgets/kfilewidget.cpp
M +10 -0 src/pathhelpers_p.h