Bug 473228

Summary: Can't use Open dialog to open files with colons in the name but no spaces anywhere before the colon
Product: [Frameworks and Libraries] frameworks-kio Reporter: Nate Graham <nate>
Component: Open/save dialogsAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: kdelibs-bugs-null, meven
Priority: NOR Keywords: qt6, regression
Version First Reported In: 5.108.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Nate Graham 2023-08-09 21:44:16 UTC
STEPS TO REPRODUCE
1. Right-click on plasma desktop > Create new > text file
2. For the file name, enter "Hello: foo.txt"
3. Open Kate built with KF6
4. In Kate go to File > Open
5. Navigate to the newly created file and open it


OBSERVED RESULT
Error message saying:
> The file "hello: foo.txt" could not be found

(note the incorrect capitalization)


EXPECTED RESULT
The file is opened.


ADDITIONAL INFORMATION
Reproduces with all apps tested that use the KDE file dialog.

Does not reproduce if I open the file by clicking it in the file manager; it opens in its default app normally.

Does NOT reproduce if the file is named  "Hello Hello: foo.txt". It seems like you need to have at least one space in the filename before the colon, and then it works.
Comment 1 Nate Graham 2023-08-09 22:34:04 UTC
Ah, this doesn't look correct:

> kf.kio.core: couldn't create worker: "Unknown protocol 'hello'."
Comment 2 Nate Graham 2023-08-10 04:18:43 UTC
This appears to have been caused by https://invent.kde.org/frameworks/kio/-/commit/ca5e0796f84c37efe69f323f0072a601af34abbf.

In that commit,
> QUrl partial_url;
> partial_url.setPath(partial_name);
Got changed to:
> QUrl partial_url(partial_name);

But that seems wrong, because it's creating a QUrl from a string and the QUrl documentation (https://doc.qt.io/qt-6/qurl.html#QUrl-2) says doing this "Will construct a valid URL but it may not be what one expects", and that's exactly what's happening here. The "Hello:" at the beginning of the string is interpreted by the QUrl constructor as a URL scheme, so it helpfully lowercases it for us generates a relative QUrl with an invalid scheme that points to nothing.

Simply reverting to the old code here fixes the issue without regressing Bug 459485.

That commit was backported to KF5 so this needs quick attention.
Comment 3 Bug Janitor Service 2023-08-10 04:40:50 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1371
Comment 4 Bug Janitor Service 2023-08-16 14:17:02 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1382
Comment 5 Méven 2023-08-17 07:25:07 UTC
Git commit 1f8976936d60979f4f329ba151d2cc870b7faf1b by Méven Car.
Committed on 17/08/2023 at 09:10.
Pushed by meven into branch 'master'.

KFileWidget: better exclude string that may look like Urls

M  +4    -0    autotests/kfilewidgettest.cpp
M  +4    -1    src/filewidgets/kfilewidget.cpp

https://invent.kde.org/frameworks/kio/-/commit/1f8976936d60979f4f329ba151d2cc870b7faf1b
Comment 6 David Faure 2023-08-17 18:29:19 UTC
Git commit eba6da115b135565c3070af2380c1de1a83946ce by David Faure, on behalf of Méven Car.
Committed on 17/08/2023 at 20:27.
Pushed by dfaure into branch 'kf5'.

KFileWidget: better exclude string that may look like Urls
(cherry picked from commit 1f8976936d60979f4f329ba151d2cc870b7faf1b)

M  +4    -0    autotests/kfilewidgettest.cpp
M  +4    -1    src/filewidgets/kfilewidget.cpp

https://invent.kde.org/frameworks/kio/-/commit/eba6da115b135565c3070af2380c1de1a83946ce