Bug 322837 - Can't open files beginning with colon (:)
Summary: Can't open files beginning with colon (:)
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Open/save dialogs (show other bugs)
Version: 5.45.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords: usability
: 267371 312226 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-07-26 06:53 UTC by kdebugs
Modified: 2020-12-12 10:19 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.78


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kdebugs 2013-07-26 06:53:06 UTC
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.

Reproducible: Always

Steps to Reproduce:
1. Open Konsole and enter these commands:
-------------
cd ~
mkdir newdir
echo "Hello World." > :
cp : :0
cp : \~
cp : \~0
cp : \"
kate \" &
exit
-------------
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:
"
:
:0
~
~0
3. Try opening any of the five files.
Actual Results:  
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.

Expected Results:  
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.
Comment 1 Jon Ander Peñalba 2013-07-26 11:57:41 UTC
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.
Comment 2 Christoph Feck 2013-08-10 23:16:01 UTC
~ (tilde) is bug 317513
" (quotes) is bug 185433

Regarding the : (colon), this could be related to Qt resources or Windows path handling.
Comment 3 Nate Graham 2018-04-10 22:02:09 UTC
Using this bug to track just the colon issue, since we have other bugs for the other characters.
Comment 4 Nate Graham 2018-04-13 16:50:52 UTC
*** Bug 267371 has been marked as a duplicate of this bug. ***
Comment 5 Nate Graham 2018-04-13 17:42:51 UTC
*** Bug 312226 has been marked as a duplicate of this bug. ***
Comment 6 Bug Janitor Service 2020-12-10 13:04:32 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/250
Comment 7 Ahmad Samir 2020-12-10 13:05:44 UTC
That MR only covers the kfilewidget case; for kate I'll open a separate report to track the issue.
Comment 8 Ahmad Samir 2020-12-10 13:11:26 UTC
I've opened bug 430216.
Comment 9 Ahmad Samir 2020-12-12 10:19:03 UTC
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),
in pathhelpers_p.h.

Extend the unit tests.
FIXED-IN: 5.78

M  +15   -6    autotests/kfilewidgettest.cpp
M  +5    -6    src/filewidgets/kfilewidget.cpp
M  +10   -0    src/pathhelpers_p.h

https://invent.kde.org/frameworks/kio/commit/c5dbb7c5452f1af637540efdf09061765c0ffb2d