Bug 418711 - URL special chars such as '#' not handle properly.
Summary: URL special chars such as '#' not handle properly.
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Open/save dialogs (show other bugs)
Version: 5.67.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
: 426485 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-03-10 16:02 UTC by Fabian Vogt
Modified: 2020-10-25 11:41 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.76


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Vogt 2020-03-10 16:02:36 UTC
1. kdialog --getsaveurl (or --getsavefilename)
2. Enter "foo#bar" in the file name field
3. Navigate by clicking on a folder, upwards or something like that
4. The filename changes to "foo%23bar", then "foo%2523bar", then "foo%252523bar" and so on

This is caused by treating the input to KComboBox as plain string representing a local path in KFileWidgetPrivate::locationEditCurrentText (QDir::fromNativeSeparators(locationEdit->currentText());), but writing a proper URL with QUrl::toDisplayString() in KComboBox::changeUrl.

Not sure what to do about that though, as the filename field is supposed to accept full URLs as well as bare filenames. While the URL "foo#bar" would represent the filename "foo" (the #fragment doesn't matter), it would be a valid local filename as-is.

The inconsistency between writing and reading the URL from KComboBox causes that on each read->write iteration, it's further encoded.
Comment 1 Bug Janitor Service 2020-10-20 15:52:46 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/178
Comment 2 Ahmad Samir 2020-10-22 17:03:24 UTC
Git commit f29ce254864ce575d12717896edcf71b35c2a30a by Ahmad Samir.
Committed on 22/10/2020 at 09:01.
Pushed by dfaure into branch 'master'.

kfilewidget: keep the text in the Name box when navigating

In _k_urlEntered, if keepLocation is true (which it is in e.g. Saving mode),
KComboBox::changeUrl() was called to update the item in the Name
KUrlComboBox, AFAIU this is mainly to show the icon of the mimetype of the
file in the KComboBox. One issue with that approach is that if the user
types "some#file" and then goes up (i.e. navigate in the view) the text will
change to "some%23file", the, '#' is encoded to %23, then going up again
will encode "%" to '%25', and the text becomes "some%2523file"... etc.

Replace changeUrl() with KComboBox::setItemIcon(), this way the icon is
updated and the text typed by the user is kept as-is. The same logic is
used through out code (e.g. setDummyHistoryEntry).

Unit test written by dfaure.
FIXED-IN: 5.76

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

https://invent.kde.org/frameworks/kio/commit/f29ce254864ce575d12717896edcf71b35c2a30a
Comment 3 Patrick Silva 2020-10-25 11:41:22 UTC
*** Bug 426485 has been marked as a duplicate of this bug. ***