Summary: | KOpenWithDialog: Wrong handling of paths with spaces | ||
---|---|---|---|
Product: | [Unmaintained] kio | Reporter: | Victor Varvaryuk <victor.varvariuc> |
Component: | kfile | Assignee: | Ingomar Wesp <ingomar> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | etienne, ingomar, plasma-bugs, rshah0385 |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 4.8 | |
Sentry Crash Report: | |||
Attachments: | example of bug |
I just got the same behaviour on my system: kubuntu 11.10 ( kde 4.7.3) I can confirmed this on 4.8 master Seems the real bug is not inside quicklaunch. Seem the checking inside KOpenWithDialog::checkAccept will not pass path with spaces. > Seems the real bug is not inside quicklaunch.
> Seem the checking inside KOpenWithDialog::checkAccept will not pass path with
> spaces.
Indeed. checkAccept calls KRun::binaryName(…) on the entered text, which treats the first space as a separator between an executable and its arguments. A reasonable solution would probably be to assume that whitespace is part of the path as long as the path denotes an existing file.
I'll try to come up with a patch for the KOpenWithDialog.
Git commit 63c7ae800b22d0d9d6d5a43a21f8e4473994298d by Ingomar Wesp. Committed on 16/01/2012 at 15:45. Pushed by iwesp into branch 'KDE/4.8'. Make sure that paths selected via the file dialog are properly quoted. Since the line edit expects shell-style quoting, this patch avoids file-not-found errors when selecting a path that contains whitespace or special characters. FIXED-IN: 4.8 REVIEW: 103602 M +9 -0 kio/kfile/kopenwithdialog.cpp M +1 -0 kio/kfile/kopenwithdialog.h http://commits.kde.org/kdelibs/63c7ae800b22d0d9d6d5a43a21f8e4473994298d edit->setText(KShell::quoteArg(edit->text())); Would it be better to quote the path when passing it the part of the application which uses it, instead of quoting it after selecting a file? This would allow manually pasting/entering a path with spaces via Ctrl-V to the line edit. Also it's not user friendly to see 'Heroes\ of\ Might ...' in the line edit. Also it would a problem to copy this path to another application, which doesn't expect '\' in the text. IMO (In reply to comment #6) > Would it be better to quote the path when passing it the part of the > application which uses it, instead of quoting it after selecting a file? Maybe. OTOH, how would you specify command line arguments then? Your proposed solution (as well as the one I initially suggested in comment #4) would require some logic that tries to guess which whitespaces are part of the path and which ones are separators of arguments. And you could still run into ambiguities: Assume the following two executables: "/bin/foo" "/bin/foo bar" When the user types "/bin/foo bar", should this be interpreted as executable "foo" with parameter "bar" or did the user mean the executable "foo bar"? > Also it's not user friendly to see 'Heroes\ of\ Might ...' in the line edit. Luckily, KShell::quoteArg returns 'Heroes of Might …', which is better IMHO. But I do see your point. Anyways, that's just my opinion, so if you're not convinced, I would suggest filing a new report (severity: wishlist) against kio/kfile. > Luckily, KShell::quoteArg returns 'Heroes of Might …', which is better IMHO.
I should have written "'Heroes of Might …'" to make it clear that the single quotes are part of the string. Sorry.
Ok, just wanted to be sure that there is no better solution. What about instead of having "path/to/My\ Application %u" after file selection put there "'path/to/My Application' %u" - smth like that? (In reply to comment #9) > Ok, just wanted to be sure that there is no better solution. I agree that this is not perfect. I'm also not the maintainer of this part of kdelibs, so I really suggest opening a new report (people will probably not see your comment if they're attached to a report that is already closed) in order to discuss this. Git commit cfc52e240ae5a15f049f578c50b9c58eadb3203a by Sebastian Trueg, on behalf of Ingomar Wesp. Committed on 16/01/2012 at 15:45. Pushed by trueg into branch 'KDE/4.8'. Make sure that paths selected via the file dialog are properly quoted. Since the line edit expects shell-style quoting, this patch avoids file-not-found errors when selecting a path that contains whitespace or special characters. FIXED-IN: 4.8 REVIEW: 103602 M +9 -0 kio/kfile/kopenwithdialog.cpp M +1 -0 kio/kfile/kopenwithdialog.h http://commits.kde.org/kdelibs/cfc52e240ae5a15f049f578c50b9c58eadb3203a |
Created attachment 63621 [details] example of bug Version: unspecified (using KDE 4.7.0) OS: Linux When adding an application launcher via Browse, it inserts path with non-escaped paths. Reproducible: Always Steps to Reproduce: Try to add launcher browsing to a path with spaces (see the attachment) Expected Results: Either selected path should be with spaces escaped with '\', or must handle paths without escaped spaces properly.