diff --git a/src/command.c b/src/command.c
index b204b8d..7764e45 100644
a
|
b
|
examine_cd (char *path) |
64 | 64 | const char *t; |
65 | 65 | |
66 | 66 | /* Tilde expansion */ |
| 67 | path = unescape_string(path); |
67 | 68 | path_tilde = tilde_expand (path); |
68 | 69 | |
69 | 70 | /* Leave space for further expansion */ |
diff --git a/src/complete.c b/src/complete.c
index 1742b85..a11b9c9 100644
a
|
b
|
|
40 | 40 | #include "wtools.h" |
41 | 41 | #include "complete.h" |
42 | 42 | #include "main.h" |
| 43 | #include "util.h" |
43 | 44 | #include "key.h" /* XCTRL and ALT macros */ |
44 | 45 | |
45 | 46 | typedef char *CompletionFunction (char *, int); |
… |
… |
query_callback (Dlg_head *h, dlg_msg_t msg, int parm) |
911 | 912 | static int |
912 | 913 | complete_engine (WInput *in, int what_to_do) |
913 | 914 | { |
| 915 | char *complete = NULL; |
914 | 916 | if (in->completions && in->point != end) |
915 | 917 | free_completions (in); |
916 | 918 | if (!in->completions){ |
… |
… |
complete_engine (WInput *in, int what_to_do) |
924 | 926 | } |
925 | 927 | if (in->completions){ |
926 | 928 | if (what_to_do & DO_INSERTION || ((what_to_do & DO_QUERY) && !in->completions[1])) { |
927 | | if (insert_text (in, in->completions [0], strlen (in->completions [0]))){ |
| 929 | complete = escape_string(in->completions [0]); |
| 930 | if (insert_text (in, complete, strlen (complete))){ |
928 | 931 | if (in->completions [1]) |
929 | 932 | beep (); |
930 | 933 | else |
… |
… |
complete_engine (WInput *in, int what_to_do) |
940 | 943 | Dlg_head *query_dlg; |
941 | 944 | WListbox *query_list; |
942 | 945 | |
943 | | for (p=in->completions + 1; *p; count++, p++) |
| 946 | for (p=in->completions + 1; *p; count++, p++) { |
| 947 | *p = escape_string(*p); |
944 | 948 | if ((i = strlen (*p)) > maxlen) |
945 | 949 | maxlen = i; |
| 950 | } |
946 | 951 | start_x = in->widget.x; |
947 | 952 | start_y = in->widget.y; |
948 | 953 | if (start_y - 2 >= count) { |
diff --git a/src/file.c b/src/file.c
index a19633a..8936e68 100644
a
|
b
|
|
63 | 63 | #include "widget.h" |
64 | 64 | #include "wtools.h" |
65 | 65 | #include "background.h" /* we_are_background */ |
| 66 | #include "util.h" |
66 | 67 | |
67 | 68 | /* Needed for current_panel, other_panel and WTree */ |
68 | 69 | #include "dir.h" |
… |
… |
copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path, |
791 | 792 | } |
792 | 793 | } |
793 | 794 | |
794 | | if (!appending) { |
| 795 | if (!appending && ctx->preserve) { |
795 | 796 | while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) { |
796 | 797 | temp_status = file_error ( |
797 | 798 | _(" Cannot chmod target file \"%s\" \n %s "), dst_path); |
… |
… |
panel_operate (void *source_panel, FileOperation operation, |
1872 | 1873 | dest = temp2; |
1873 | 1874 | temp = NULL; |
1874 | 1875 | |
| 1876 | source_with_path = unescape_string(source_with_path); |
| 1877 | dest = unescape_string(dest); |
1875 | 1878 | switch (operation) { |
1876 | 1879 | case OP_COPY: |
1877 | 1880 | /* |
… |
… |
panel_operate (void *source_panel, FileOperation operation, |
1963 | 1966 | else { |
1964 | 1967 | char *temp2 = concat_dir_and_file (dest, temp); |
1965 | 1968 | |
| 1969 | source_with_path = unescape_string(source_with_path); |
| 1970 | temp2 = unescape_string(temp2); |
| 1971 | |
1966 | 1972 | switch (operation) { |
1967 | 1973 | case OP_COPY: |
1968 | 1974 | /* |
diff --git a/src/util.c b/src/util.c
index da6d1b2..b076168 100644
a
|
b
|
Q_ (const char *s) |
1525 | 1525 | return (sep != NULL) ? sep + 1 : result; |
1526 | 1526 | } |
1527 | 1527 | |
| 1528 | /* Unescape paths or other strings for e.g the internal cd */ |
| 1529 | char * |
| 1530 | unescape_string(const char *in) { |
| 1531 | GString *str; |
| 1532 | const char * src; |
| 1533 | char *result; |
| 1534 | |
| 1535 | str = g_string_new(""); |
| 1536 | |
| 1537 | for (src = in; *src != '\0'; src++) { |
| 1538 | if (src[0] == '\\' && strchr(" !#$%&'()*;<>?[]`{|}~", src[1])) { |
| 1539 | g_string_append_c(str, src[1]); |
| 1540 | src++; |
| 1541 | } else { |
| 1542 | g_string_append_c(str, src[0]); |
| 1543 | } |
| 1544 | } |
| 1545 | |
| 1546 | result = str->str; |
| 1547 | g_string_free(str, FALSE); |
| 1548 | return result; |
| 1549 | } |
| 1550 | /* To be compatible with the general posix command lines we have to escape * |
| 1551 | * strings for the command line */ |
| 1552 | char * |
| 1553 | escape_string ( const char * in ) { |
| 1554 | GString *str; |
| 1555 | const char * src; |
| 1556 | char *result; |
| 1557 | |
| 1558 | str = g_string_new(""); |
| 1559 | |
| 1560 | for (src = in;src[0] != '\0';src++) { |
| 1561 | if ( (src[-1] != '\\') && strchr(" !#$%&'()*;<>?[]`{|}~",src[0])) { |
| 1562 | g_string_append_c(str,'\\'); |
| 1563 | g_string_append_c(str,src[0]); |
| 1564 | } else { |
| 1565 | g_string_append_c(str,src[0]); |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | result = str->str; |
| 1570 | g_string_free(str, FALSE); |
| 1571 | return result; |
| 1572 | } |
diff --git a/src/util.h b/src/util.h
index 4e9a113..9c69e99 100644
a
|
b
|
extern char *str_unconst (const char *); |
14 | 14 | extern const char *cstrcasestr (const char *haystack, const char *needle); |
15 | 15 | extern const char *cstrstr (const char *haystack, const char *needle); |
16 | 16 | |
| 17 | char *unescape_string ( const char * in ); |
| 18 | char *escape_string ( const char * in ); |
17 | 19 | void str_replace(char *s, char from, char to); |
18 | 20 | int is_printable (int c); |
19 | 21 | void msglen (const char *text, /*@out@*/ int *lines, /*@out@*/ int *columns); |