Original patch as attached on the bugreport
Этот коммит содержится в:
родитель
d79dfa1324
Коммит
5041bd41f6
@ -64,6 +64,7 @@ examine_cd (char *path)
|
||||
const char *t;
|
||||
|
||||
/* Tilde expansion */
|
||||
path = unescape_string(path);
|
||||
path_tilde = tilde_expand (path);
|
||||
|
||||
/* Leave space for further expansion */
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "wtools.h"
|
||||
#include "complete.h"
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
#include "key.h" /* XCTRL and ALT macros */
|
||||
|
||||
typedef char *CompletionFunction (char *, int);
|
||||
@ -911,6 +912,7 @@ query_callback (Dlg_head *h, dlg_msg_t msg, int parm)
|
||||
static int
|
||||
complete_engine (WInput *in, int what_to_do)
|
||||
{
|
||||
char *complete = NULL;
|
||||
if (in->completions && in->point != end)
|
||||
free_completions (in);
|
||||
if (!in->completions){
|
||||
@ -924,7 +926,8 @@ complete_engine (WInput *in, int what_to_do)
|
||||
}
|
||||
if (in->completions){
|
||||
if (what_to_do & DO_INSERTION || ((what_to_do & DO_QUERY) && !in->completions[1])) {
|
||||
if (insert_text (in, in->completions [0], strlen (in->completions [0]))){
|
||||
complete = escape_string(in->completions [0]);
|
||||
if (insert_text (in, complete, strlen (complete))){
|
||||
if (in->completions [1])
|
||||
beep ();
|
||||
else
|
||||
@ -940,9 +943,11 @@ complete_engine (WInput *in, int what_to_do)
|
||||
Dlg_head *query_dlg;
|
||||
WListbox *query_list;
|
||||
|
||||
for (p=in->completions + 1; *p; count++, p++)
|
||||
for (p=in->completions + 1; *p; count++, p++) {
|
||||
*p = escape_string(*p);
|
||||
if ((i = strlen (*p)) > maxlen)
|
||||
maxlen = i;
|
||||
}
|
||||
start_x = in->widget.x;
|
||||
start_y = in->widget.y;
|
||||
if (start_y - 2 >= count) {
|
||||
|
@ -63,6 +63,7 @@
|
||||
#include "widget.h"
|
||||
#include "wtools.h"
|
||||
#include "background.h" /* we_are_background */
|
||||
#include "util.h"
|
||||
|
||||
/* Needed for current_panel, other_panel and WTree */
|
||||
#include "dir.h"
|
||||
@ -791,7 +792,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
|
||||
}
|
||||
}
|
||||
|
||||
if (!appending) {
|
||||
if (!appending && ctx->preserve) {
|
||||
while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) {
|
||||
temp_status = file_error (
|
||||
_(" Cannot chmod target file \"%s\" \n %s "), dst_path);
|
||||
@ -1872,6 +1873,8 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
dest = temp2;
|
||||
temp = NULL;
|
||||
|
||||
source_with_path = unescape_string(source_with_path);
|
||||
dest = unescape_string(dest);
|
||||
switch (operation) {
|
||||
case OP_COPY:
|
||||
/*
|
||||
@ -1963,6 +1966,9 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
else {
|
||||
char *temp2 = concat_dir_and_file (dest, temp);
|
||||
|
||||
source_with_path = unescape_string(source_with_path);
|
||||
temp2 = unescape_string(temp2);
|
||||
|
||||
switch (operation) {
|
||||
case OP_COPY:
|
||||
/*
|
||||
|
55
src/util.c
55
src/util.c
@ -1527,3 +1527,58 @@ Q_ (const char *s)
|
||||
return (sep != NULL) ? sep + 1 : result;
|
||||
}
|
||||
|
||||
/* Unescape paths or other strings for e.g the internal cd */
|
||||
char *
|
||||
unescape_string ( const char * in ) {
|
||||
char * local = NULL;
|
||||
int i = 0;
|
||||
int j = 20;
|
||||
int k = 0;
|
||||
|
||||
local = g_malloc(j);
|
||||
|
||||
for (i=0;i<=strlen(in);i++) {
|
||||
if (i-k+1 >= j ) {
|
||||
j = j + 20;
|
||||
local = g_realloc(local,j);
|
||||
}
|
||||
if ( (strchr(" \t*|;<>~#()?[]{}&",in[i])) && ( strchr("\\",in[i-1])) ) {
|
||||
k++;
|
||||
local[i-k] = in[i];
|
||||
} else {
|
||||
local[i-k] = in[i];
|
||||
}
|
||||
}
|
||||
local[i-k] = '\0';
|
||||
|
||||
return local;
|
||||
}
|
||||
|
||||
/* To be compatible with the general posix command lines we have to escape *
|
||||
* strings for the command line */
|
||||
char *
|
||||
escape_string ( const char * in ) {
|
||||
char * local = NULL;
|
||||
int i = 0;
|
||||
int j = 20;
|
||||
int k = 0;
|
||||
|
||||
local = g_malloc(j);
|
||||
|
||||
for (i=0;i<strlen(in);i++) {
|
||||
if (i+k+1 >= j ) { //If 20 chars is too low for the path
|
||||
j = j + 20;
|
||||
local = g_realloc(local,j);
|
||||
}
|
||||
if ( (strchr(" \t*|;<>~#()?[]{}&",in[i])) && (! strchr("\\",in[i-1])) ) {
|
||||
local[i+k] = 92; // Ascii for "\"
|
||||
k = k+1;
|
||||
local[i+k] = in[i];
|
||||
} else {
|
||||
local[i+k] = in[i];
|
||||
}
|
||||
}
|
||||
local[i+k] = '\0';
|
||||
|
||||
return local;
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ extern char *str_unconst (const char *);
|
||||
extern const char *cstrcasestr (const char *haystack, const char *needle);
|
||||
extern const char *cstrstr (const char *haystack, const char *needle);
|
||||
|
||||
char *unescape_string ( const char * in );
|
||||
char *escape_string ( const char * in );
|
||||
void str_replace(char *s, char from, char to);
|
||||
int is_printable (int c);
|
||||
void msglen (const char *text, /*@out@*/ int *lines, /*@out@*/ int *columns);
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user