Summary: | Open/save dialog cannot open or save filenames containing double quotes | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kio | Reporter: | Inge Wallin <inge> |
Component: | Open/save dialogs | Assignee: | Andreas Bontozoglou <a.bontozoglou> |
Status: | RESOLVED FIXED | ||
Severity: | major | CC: | a.bontozoglou, adaptee, adawit, arthur, benhuan, brendon, bugseforuns, bugzilla.kde, chshu, ereslibre, faure, glyphimor, grosser.meister.morti, hessijames, kdelibs-bugs, kdespam34fb987, lukasz.wojnilowicz, mail, nate, pascal, stharward, walch.martin |
Priority: | VHI | Keywords: | testcase, usability |
Version: | 5.45.0 | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Unspecified | ||
See Also: | https://bugs.kde.org/show_bug.cgi?id=426728 | ||
Latest Commit: | https://invent.kde.org/frameworks/kio/commit/87adf7f6bcbd9baddafda58e2dbf7052eb323358 | Version Fixed In: | |
Sentry Crash Report: |
Description
Inge Wallin
2009-02-24 13:31:50 UTC
Yes, happens with kwrite too. Must be the code for multi-selecting files ("a.txt "b.txt"), which removes double-quotes automatically. *** Bug 211739 has been marked as a duplicate of this bug. *** *** Bug 218194 has been marked as a duplicate of this bug. *** *** Bug 308277 has been marked as a duplicate of this bug. *** I ran into this bug with Amarok. It's not just multi-select. It's that when the dialog's selectedUrls() function is called, the URL being returned contains only the portion of the filename that's within the quotes. So if I had the files: /home/user/"test".txt /home/user/this_is_"a_test".txt calling KFileDialog::selectedUrls() would return KUrl("file:///home/user/test") KUrl("file:///home/user/a_test") *** Bug 189935 has been marked as a duplicate of this bug. *** Someone needs to fix KFileWidget (kdelibs/kfile/kfilewidget.cpp)... Line #1641 at contains the following statement: // FIXME: current implementation drawback: a filename can't contain quotes Unless that is resolved this problem will remain. The multi-selection code seems to be a problem in general. E. g. selecting files containing percent signs only works in single-selection mode. Meaning there are two code paths which is bad for testing. @Soren: If a filename contains double quotes, it is falsely detected as a multi-selection string and everything outside of the quotes gets ignored. This is more serious than it says on the tin. It affects _saving_ files too...save to FooDoc("quotes").file, and pretty much every KDE app will write to 'quotes'. Best-case, the file isn't saved to where the user expected it but they notice. Worse, it's saved somewhere else and they think they've lost all their work. At least there's a popup before clobbering 'quotes' if it exists, but people aren't good at paying attention to those. *** Bug 362613 has been marked as a duplicate of this bug. *** *** Bug 329258 has been marked as a duplicate of this bug. *** #c8 mentions percent signs - there are also question marks which cause problems, see Bug 329259 ... possibly a related cause. (In reply to realnobody from comment #12) forget that, I just tried again - and it seems the mentioned "?" case if fixed in the meantime. *** Bug 355821 has been marked as a duplicate of this bug. *** *** Bug 424702 has been marked as a duplicate of this bug. *** A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/89 Taking this over with an open MR - feel free to take back Thanks for working on this, Andreas! Much appreciated. Git commit 87adf7f6bcbd9baddafda58e2dbf7052eb323358 by David Faure, on behalf of Andreas Bontozoglou. Committed on 12/09/2020 at 18:03. Pushed by dfaure into branch 'master'. [kio] BUG: Allowing double-quotes in open/save dialog tl;dr: Allowing double-quotes in filenames in KFileWidget by escaping them with `\` and modifying the tokenizer to understand this. In this patch: - Introduce `escapeDoubleQuotes` function that is used to escape selected file paths and correctly populate the `locationEdit` - Disabling old KFileWidgetPrivate::tokenize and writing a new one which works by iterating each character in the `locationEdit` while it remembers if it is in "escape mode" (seen a '\') or not. - Introducing **public API** `KFileWidget::setSelectedUrls`. This was mainly needed for the tests to work. I originally wanted to test only the tokenizer but (a) this is in private implementation and (b) testing that things are escaped properly in the text-box is also very important - Adding a test for various filenames that contain a mix of backslashes and quotes - Adding a new logging category for the kfilewidget.cpp (KIO_KFILEWIDGETS_FW) - Adding command-line options to `kfilewidgettest_saving_gui` which I used for functional tests at some point. My work there is a bit sloppy atm but I assume this is an auxiliary file (let me now if you want me to clean it up) Questions: - Do I need to add a @since in the docblock? - Do I need to change minor/major version here (and how would I do this)? I am not sure if the addition of `setSelectedUrls` is backwards compatible M +105 -0 autotests/kfilewidgettest.cpp M +9 -0 src/filewidgets/CMakeLists.txt M +98 -46 src/filewidgets/kfilewidget.cpp M +8 -0 src/filewidgets/kfilewidget.h M +25 -7 tests/kfilewidgettest_saving_gui.cpp https://invent.kde.org/frameworks/kio/commit/87adf7f6bcbd9baddafda58e2dbf7052eb323358 |