Bug 220092 - Unquoted/unescaped directory name passed to "cd" command in dolphin embedded terminal
Summary: Unquoted/unescaped directory name passed to "cd" command in dolphin embedded ...
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 16.12.2
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Peter Penz
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2009-12-25 21:12 UTC by Juliano F. Ravasi
Modified: 2010-01-28 00:47 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juliano F. Ravasi 2009-12-25 21:12:18 UTC
Version:           1.3 (using KDE 4.3.4)
OS:                Linux
Installed from:    Ubuntu Packages

When the embedded terminal is open and you change the directory in dolphin, it sends "cd $DIR" to the terminal (where $DIR is the target directory).

If the directory name contains some reserved shell characters, like spaces, asterisks or question marks, $DIR is properly quoted. But if the directory name contains '[' or ']', which are also special shell operators (wildcard), the argument doesn't get quoted.

To reproduce:
1. Create two directories: "abc" and "ab[c]"
2. Click on "ab[c]"

Result:
* Dolphin sends "cd ab[c]" to the terminal, going into directory "abc".

Expected behavior:
* Dolphin sends "cd 'ab[c]'" to the terminal, going into directory "ab[c]".
Comment 1 Juliano F. Ravasi 2009-12-25 21:21:32 UTC
After doing some more tests, '!' has the same problem. Most interactive shells use '!' as a history recall shortcut.

To reproduce:
1. Create a directory named "!!".
2. Change to it.
3. See what happens in the terminal.

While you are at it, it should also be a good idea to add '~' to the list of characters that trigger quoting.

Recap: add '[', ']', '!' and '~' to the characters in the directory name that trigger the quoting of the parameter to 'cd' sent to the terminal.
Comment 2 Nicolas L. 2010-01-13 23:15:48 UTC
i will try to look into this bug
Comment 3 Nicolas L. 2010-01-14 17:13:13 UTC
i created a patch adding ~ ! [ and ] to the special letters:


can someone review and tell me if i can commit ?


Index: kdecore/util/kshell_unix.cpp
===================================================================
--- kdecore/util/kshell_unix.cpp        (révision 1074635)
+++ kdecore/util/kshell_unix.cpp        (copie de travail)
 -265,9 +265,9 @@
 inline static bool isSpecial( QChar cUnicode )
 {
     static const uchar iqm[] = {
-        0xff, 0xff, 0xff, 0xff, 0xdd, 0x07, 0x00, 0xd8,
-        0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x38
-    }; // 0-32 \'"$`<>|;&(){}*?#
+        0xff, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0xd8,
+        0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78
+    }; // 0-32 \'"$`<>|;&(){}*?#!~[]

     uint c = cUnicode.unicode ();
     return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7)));
Comment 4 Peter Penz 2010-01-15 14:33:17 UTC
Thanks a lot Nicolas. Might it be possible that you submit your patch at the review board (http://reviewboard.kde.org)? The patch looks good IMO, but it would be good if more kde-core developers have a look on this... Thank you!
Comment 5 Nicolas L. 2010-01-23 22:03:23 UTC
i just created a request : http://reviewboard.kde.org/r/2703/
Comment 6 Nicolas L. 2010-01-28 00:47:22 UTC
SVN commit 1081242 by nlecureuil:

quote the tilde, square brackets and the exclamation mark
Add square brackets as meta
Reviewed: http://reviewboard.kde.org/r/2703/
BUG:220092


 M  +5 -5      kshell_unix.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1081242