Browse Source

Ticket #4292: fix redundant back slashes for autocomplete.

Steps to reproduce:

1. Create file owth a space in the name:
  touch "a b"
There should no other files with name begins with "a" in the directory.
2. Press Shift-F4 to open editor
3. Press Shift-F2 to display dialog window "Save as..."
4. Press Esc+Tab to fill an input line

Result:
a\ b will appear in the edit field.
If you attempt to save the file, the back slash will be in the filename.

Expected result:
no any extra back slashes in the file name.

Soution: escape only '?', '*', and '&' symbols as described in the
manual page (see a11995e12b88285e044f644904c306ed6c342ad0).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 10 months ago
parent
commit
2ee620f74f
1 changed files with 5 additions and 4 deletions
  1. 5 4
      lib/widget/input_complete.c

+ 5 - 4
lib/widget/input_complete.c

@@ -1367,9 +1367,8 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
 
 
     g_free (state.word);
     g_free (state.word);
 
 
-    if (matches != NULL &&
-        (flags & (INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_SHELL_ESC)) !=
-        (INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_SHELL_ESC))
+    if (matches != NULL && (flags & INPUT_COMPLETE_FILENAMES) != 0 &&
+        (flags & INPUT_COMPLETE_SHELL_ESC) == 0)
     {
     {
         /* FIXME: HACK? INPUT_COMPLETE_SHELL_ESC is used only in command line. */
         /* FIXME: HACK? INPUT_COMPLETE_SHELL_ESC is used only in command line. */
         char **m;
         char **m;
@@ -1379,7 +1378,9 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
             char *p;
             char *p;
 
 
             p = *m;
             p = *m;
-            *m = str_shell_escape (*m);
+            /* Escape only '?', '*', and '&' symbols as described in the
+               manual page (see a11995e12b88285e044f644904c306ed6c342ad0). */
+            *m = str_escape (*m, -1, "?*&", TRUE);
             g_free (p);
             g_free (p);
         }
         }
     }
     }