mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Changes to handle vfs_path_t object:
* removed strip_password () function; * Added new vfs_path flag: VPF_HIDE_CHARSET; * added vfs_path_add_element() function. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
7f974fdbbb
commit
9dad3cf45c
105
lib/util.c
105
lib/util.c
@ -326,9 +326,15 @@ fake_name_quote (const char *s, int quote_percent)
|
||||
const char *
|
||||
path_trunc (const char *path, size_t trunc_len)
|
||||
{
|
||||
char *secure_path = strip_password (g_strdup (path), 1);
|
||||
vfs_path_t *vpath;
|
||||
char *secure_path;
|
||||
const char *ret;
|
||||
|
||||
const char *ret = str_trunc (secure_path, trunc_len);
|
||||
vpath = vfs_path_from_str (path);
|
||||
secure_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_PASSWORD);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
ret = str_trunc (secure_path, trunc_len);
|
||||
g_free (secure_path);
|
||||
|
||||
return ret;
|
||||
@ -564,101 +570,6 @@ string_perm (mode_t mode_bits)
|
||||
return mode;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* p: string which might contain an url with a password (this parameter is
|
||||
* modified in place).
|
||||
* has_prefix = 0: The first parameter is an url without a prefix
|
||||
* (user[:pass]@]machine[:port][remote-dir). Delete
|
||||
* the password.
|
||||
* has_prefix = 1: Search p for known url prefixes. If found delete
|
||||
* the password from the url.
|
||||
* Caveat: only the first url is found
|
||||
*/
|
||||
|
||||
char *
|
||||
strip_password (char *p, int has_prefix)
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
size_t len;
|
||||
} prefixes[] =
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
{ "/#ftp:", 6 },
|
||||
{ "ftp://", 6 },
|
||||
{ "/#smb:", 6 },
|
||||
{ "smb://", 6 },
|
||||
{ "/#sh:", 5 },
|
||||
{ "sh://", 5 },
|
||||
{ "ssh://", 6 }
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
char *at, *inner_colon, *dir;
|
||||
size_t i;
|
||||
char *result = p;
|
||||
|
||||
for (i = 0; i < sizeof (prefixes) / sizeof (prefixes[0]); i++)
|
||||
{
|
||||
char *q;
|
||||
|
||||
if (has_prefix)
|
||||
{
|
||||
q = strstr (p, prefixes[i].name);
|
||||
if (q == NULL)
|
||||
continue;
|
||||
else
|
||||
p = q + prefixes[i].len;
|
||||
}
|
||||
|
||||
dir = strchr (p, PATH_SEP);
|
||||
if (dir != NULL)
|
||||
*dir = '\0';
|
||||
|
||||
/* search for any possible user */
|
||||
at = strrchr (p, '@');
|
||||
|
||||
if (dir)
|
||||
*dir = PATH_SEP;
|
||||
|
||||
/* We have a username */
|
||||
if (at)
|
||||
{
|
||||
inner_colon = memchr (p, ':', at - p);
|
||||
if (inner_colon)
|
||||
memmove (inner_colon, at, strlen (at) + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
const char *
|
||||
strip_home_and_password (const char *dir)
|
||||
{
|
||||
size_t len;
|
||||
static char newdir[MC_MAXPATHLEN];
|
||||
|
||||
len = strlen (mc_config_get_home_dir ());
|
||||
if (mc_config_get_home_dir () != NULL && strncmp (dir, mc_config_get_home_dir (), len) == 0 &&
|
||||
(dir[len] == PATH_SEP || dir[len] == '\0'))
|
||||
{
|
||||
newdir[0] = '~';
|
||||
g_strlcpy (&newdir[1], &dir[len], sizeof (newdir) - 1);
|
||||
return newdir;
|
||||
}
|
||||
|
||||
/* We do not strip homes in /#ftp tree, I do not like ~'s there
|
||||
(see ftpfs.c why) */
|
||||
g_strlcpy (newdir, dir, sizeof (newdir));
|
||||
strip_password (newdir, 1);
|
||||
return newdir;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
const char *
|
||||
|
@ -109,12 +109,6 @@ const char *size_trunc_sep (uintmax_t size, gboolean use_si);
|
||||
void size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gboolean use_si);
|
||||
const char *string_perm (mode_t mode_bits);
|
||||
|
||||
/* @modifies path. @returns pointer into path. */
|
||||
char *strip_password (char *path, int has_prefix);
|
||||
|
||||
/* @returns a pointer into a static buffer. */
|
||||
const char *strip_home_and_password (const char *dir);
|
||||
|
||||
const char *extension (const char *);
|
||||
const char *unix_error_string (int error_num);
|
||||
const char *skip_separators (const char *s);
|
||||
|
@ -643,10 +643,13 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl
|
||||
|
||||
if ((flags & VPF_RECODE) == 0 && vfs_path_element_need_cleanup_converter (element))
|
||||
{
|
||||
if (buffer->str[buffer->len - 1] != PATH_SEP)
|
||||
if ((flags & VPF_HIDE_CHARSET) == 0)
|
||||
{
|
||||
if (buffer->len == 0 || buffer->str[buffer->len - 1] != PATH_SEP)
|
||||
g_string_append (buffer, PATH_SEP_STR);
|
||||
g_string_append (buffer, VFS_ENCODING_PREFIX);
|
||||
g_string_append (buffer, element->encoding);
|
||||
}
|
||||
str_vfs_convert_from (element->dir.converter, element->path, recode_buffer);
|
||||
vfs_append_from_path (recode_buffer->str);
|
||||
g_string_set_size (recode_buffer, 0);
|
||||
@ -778,6 +781,19 @@ vfs_path_elements_count (const vfs_path_t * vpath)
|
||||
return (vpath != NULL && vpath->path != NULL) ? vpath->path->len : 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Add vfs_path_element_t object to end of list in vfs_path_t object
|
||||
* @param vpath pointer to vfs_path_t object
|
||||
* @param path_element pointer to vfs_path_element_t object
|
||||
*/
|
||||
|
||||
void
|
||||
vfs_path_add_element (const vfs_path_t * vpath, const vfs_path_element_t * path_element)
|
||||
{
|
||||
g_array_append_val (vpath->path, path_element);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*
|
||||
* Get one path element by index.
|
||||
|
@ -14,7 +14,8 @@ typedef enum
|
||||
VPF_USE_DEPRECATED_PARSER = 1 << 1,
|
||||
VPF_RECODE = 1 << 2,
|
||||
VPF_STRIP_HOME = 1 << 3,
|
||||
VPF_STRIP_PASSWORD = 1 << 4
|
||||
VPF_STRIP_PASSWORD = 1 << 4,
|
||||
VPF_HIDE_CHARSET = 1 << 5
|
||||
} vfs_path_flag_t;
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
@ -68,6 +69,7 @@ size_t vfs_path_tokens_count (const vfs_path_t *);
|
||||
char *vfs_path_tokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t length);
|
||||
vfs_path_t *vfs_path_vtokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t length);
|
||||
|
||||
void vfs_path_add_element (const vfs_path_t * vpath, const vfs_path_element_t * path_element);
|
||||
vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, int element_index);
|
||||
vfs_path_element_t *vfs_path_element_clone (const vfs_path_element_t * element);
|
||||
void vfs_path_element_free (vfs_path_element_t * element);
|
||||
|
@ -237,14 +237,19 @@ push_history (WInput * in, const char *text)
|
||||
if (in->history_name != NULL)
|
||||
{
|
||||
/* FIXME: It is the strange code. Rewrite is needed. */
|
||||
|
||||
const char *p = in->history_name + 3;
|
||||
|
||||
for (i = 0; i < ELEMENTS; i++)
|
||||
if (strcmp (p, password_input_fields[i]) == 0)
|
||||
break;
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
strip_password (t, i >= ELEMENTS);
|
||||
vpath = vfs_path_from_str (t);
|
||||
g_free (t);
|
||||
t = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_PASSWORD);
|
||||
vfs_path_free (vpath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (in->history == NULL || in->history->data == NULL || strcmp (in->history->data, t) != 0 ||
|
||||
|
@ -2718,6 +2718,8 @@ dview_status (const WDiff * dview, int ord, int width, int c)
|
||||
const char *buf;
|
||||
int filename_width;
|
||||
int linenum, lineofs;
|
||||
vfs_path_t *vpath;
|
||||
char *path;
|
||||
|
||||
tty_setcolor (STATUSBAR_COLOR);
|
||||
|
||||
@ -2728,12 +2730,16 @@ dview_status (const WDiff * dview, int ord, int width, int c)
|
||||
if (filename_width < 8)
|
||||
filename_width = 8;
|
||||
|
||||
buf = str_term_trim (strip_home_and_password (dview->label[ord]), filename_width);
|
||||
vpath = vfs_path_from_str (dview->label[ord]);
|
||||
path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD);
|
||||
vfs_path_free (vpath);
|
||||
buf = str_term_trim (path, filename_width);
|
||||
if (ord == 0)
|
||||
tty_printf ("%-*s %6d+%-4d Col %-4d ", filename_width, buf, linenum, lineofs,
|
||||
dview->skip_cols);
|
||||
else
|
||||
tty_printf ("%-*s %6d+%-4d Dif %-4d ", filename_width, buf, linenum, lineofs, dview->ndiff);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1699,17 +1699,18 @@ dirsizes_cmd (void)
|
||||
void
|
||||
save_setup_cmd (void)
|
||||
{
|
||||
char *d1;
|
||||
const char *d2;
|
||||
vfs_path_t *vpath;
|
||||
char *path;
|
||||
|
||||
d1 = mc_config_get_full_path (MC_CONFIG_FILE);
|
||||
d2 = strip_home_and_password (d1);
|
||||
g_free (d1);
|
||||
vpath = mc_config_get_full_vpath (MC_CONFIG_FILE);
|
||||
path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
if (save_setup (TRUE, TRUE))
|
||||
message (D_NORMAL, _("Setup"), _("Setup saved to %s"), d2);
|
||||
message (D_NORMAL, _("Setup"), _("Setup saved to %s"), path);
|
||||
else
|
||||
message (D_ERROR, _("Setup"), _("Unable to save setup to %s"), d2);
|
||||
message (D_ERROR, _("Setup"), _("Unable to save setup to %s"), path);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -436,9 +436,10 @@ do_cd_command (char *orig_cmd)
|
||||
{
|
||||
char *d;
|
||||
|
||||
d = strip_password (path, 1);
|
||||
d = vfs_path_to_str_flags (q_vpath, 0, VPF_STRIP_PASSWORD);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\"\n%s"), d,
|
||||
unix_error_string (errno));
|
||||
g_free (d);
|
||||
}
|
||||
|
||||
vfs_path_free (q_vpath);
|
||||
|
@ -341,9 +341,10 @@ overwrite_query_dialog (FileOpContext * ctx, enum OperationMode mode)
|
||||
|
||||
char buffer[BUF_SMALL];
|
||||
const char *title;
|
||||
const char *stripped_name = strip_home_and_password (ui->replace_filename);
|
||||
int stripped_name_len;
|
||||
|
||||
vfs_path_t *stripped_vpath;
|
||||
const char *stripped_name;
|
||||
char *stripped_name_orig;
|
||||
int result;
|
||||
|
||||
widgets_len = g_new0 (int, num);
|
||||
@ -353,6 +354,10 @@ overwrite_query_dialog (FileOpContext * ctx, enum OperationMode mode)
|
||||
else
|
||||
title = _("Background process: File exists");
|
||||
|
||||
stripped_vpath = vfs_path_from_str (ui->replace_filename);
|
||||
stripped_name = stripped_name_orig =
|
||||
vfs_path_to_str_flags (stripped_vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD);
|
||||
vfs_path_free (stripped_vpath);
|
||||
stripped_name_len = str_term_width1 (stripped_name);
|
||||
|
||||
{
|
||||
@ -454,6 +459,7 @@ overwrite_query_dialog (FileOpContext * ctx, enum OperationMode mode)
|
||||
destroy_dlg (ui->replace_dlg);
|
||||
|
||||
g_free (widgets_len);
|
||||
g_free (stripped_name_orig);
|
||||
|
||||
return (result == B_CANCEL) ? REPLACE_ABORT : (replace_action_t) result;
|
||||
#undef ADD_RD_LABEL
|
||||
@ -1060,7 +1066,13 @@ file_mask_dialog (FileOpContext * ctx, FileOperation operation,
|
||||
ctx->op_preserve = filegui__check_attrs_on_fs (def_text);
|
||||
|
||||
/* filter out a possible password from def_text */
|
||||
tmp = strip_password (g_strdup (def_text), 1);
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str (def_text);
|
||||
tmp = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_PASSWORD);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
if (source_easy_patterns)
|
||||
def_text_secure = strutils_glob_escape (tmp);
|
||||
else
|
||||
|
@ -1092,7 +1092,7 @@ add_new_entry_cmd (void)
|
||||
int ret;
|
||||
|
||||
/* Take current directory as default value for input fields */
|
||||
to_free = title = url = strip_password (vfs_path_to_str (current_panel->cwd_vpath), 1);
|
||||
to_free = title = url = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_STRIP_PASSWORD);
|
||||
|
||||
ret = add_new_entry_input (_("New hotlist entry"), _("Directory label:"),
|
||||
_("Directory path:"), "[Hotlist]", &title, &url);
|
||||
@ -1688,19 +1688,18 @@ add_dotdot_to_list (void)
|
||||
void
|
||||
add2hotlist_cmd (void)
|
||||
{
|
||||
char *lc_prompt, *label;
|
||||
char *lc_prompt;
|
||||
const char *cp = N_("Label for \"%s\":");
|
||||
int l;
|
||||
char *label_string;
|
||||
char *label_string, *label;
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
cp = _(cp);
|
||||
#endif
|
||||
|
||||
l = str_term_width1 (cp);
|
||||
label_string = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
lc_prompt = g_strdup_printf (cp, path_trunc (label_string, COLS - 2 * UX - (l + 8)));
|
||||
strip_password (label_string, 1);
|
||||
label_string = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_STRIP_PASSWORD);
|
||||
lc_prompt = g_strdup_printf (cp, str_trunc (label_string, COLS - 2 * UX - (l + 8)));
|
||||
label = input_dialog (_("Add to hotlist"), lc_prompt, MC_HISTORY_HOTLIST_ADD, label_string);
|
||||
g_free (lc_prompt);
|
||||
|
||||
@ -1712,6 +1711,7 @@ add2hotlist_cmd (void)
|
||||
}
|
||||
add2hotlist (label, label_string, HL_TYPE_ENTRY, LISTBOX_APPEND_AT_END);
|
||||
hotlist_state.modified = 1;
|
||||
g_free (label_string);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -431,18 +431,18 @@ midnight_get_title (const Dlg_head * h, size_t len)
|
||||
{
|
||||
/* TODO: share code with update_xterm_title_path() */
|
||||
|
||||
const char *path;
|
||||
char *path_origin, *p;
|
||||
char *path;
|
||||
char host[BUF_TINY];
|
||||
char *p;
|
||||
struct passwd *pw = NULL;
|
||||
char *login = NULL;
|
||||
int res = 0;
|
||||
|
||||
(void) h;
|
||||
|
||||
p = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
path = strip_home_and_password (p);
|
||||
g_free (p);
|
||||
path_origin =
|
||||
vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD);
|
||||
|
||||
res = gethostname (host, sizeof (host));
|
||||
if (res != 0)
|
||||
host[0] = '\0';
|
||||
@ -455,12 +455,13 @@ midnight_get_title (const Dlg_head * h, size_t len)
|
||||
else
|
||||
login = g_strdup (host);
|
||||
|
||||
p = g_strdup_printf ("%s [%s]:%s", _("Panels:"), login, path);
|
||||
path = str_trunc (p, len - 4);
|
||||
p = g_strdup_printf ("%s [%s]:%s", _("Panels:"), login, path_origin);
|
||||
g_free (path_origin);
|
||||
path = g_strdup (str_trunc (p, len - 4));
|
||||
g_free (login);
|
||||
g_free (p);
|
||||
|
||||
return g_strdup (path);
|
||||
return path;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1081,37 +1081,19 @@ show_free_space (WPanel * panel)
|
||||
static char *
|
||||
panel_correct_path_to_show (WPanel * panel)
|
||||
{
|
||||
vfs_path_t *last_vpath;
|
||||
const vfs_path_element_t *path_element;
|
||||
GString *ret_str;
|
||||
char *return_path;
|
||||
|
||||
path_element = vfs_path_get_by_index (panel->cwd_vpath, -1);
|
||||
ret_str = g_string_new ("");
|
||||
last_vpath = vfs_path_new ();
|
||||
path_element = vfs_path_element_clone (vfs_path_get_by_index (panel->cwd_vpath, -1));
|
||||
vfs_path_add_element (last_vpath, path_element);
|
||||
return_path =
|
||||
vfs_path_to_str_flags (last_vpath, 0,
|
||||
VPF_STRIP_HOME | VPF_STRIP_PASSWORD | VPF_HIDE_CHARSET);
|
||||
vfs_path_free (last_vpath);
|
||||
|
||||
if ((path_element->class->flags & VFSF_LOCAL) == 0)
|
||||
{
|
||||
char *url_str;
|
||||
|
||||
g_string_append (ret_str, path_element->vfs_prefix);
|
||||
g_string_append (ret_str, VFS_PATH_URL_DELIMITER);
|
||||
|
||||
url_str = vfs_path_build_url_params_str (path_element, FALSE);
|
||||
if (*url_str != '\0')
|
||||
{
|
||||
g_string_append (ret_str, url_str);
|
||||
g_string_append_c (ret_str, PATH_SEP);
|
||||
}
|
||||
g_free (url_str);
|
||||
g_string_append (ret_str, path_element->path);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *tmp_path;
|
||||
|
||||
tmp_path = g_strdup (path_element->path);
|
||||
g_string_append (ret_str, strip_home_and_password (tmp_path));
|
||||
g_free (tmp_path);
|
||||
}
|
||||
return g_string_free (ret_str, FALSE);
|
||||
return return_path;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -3243,7 +3225,7 @@ panel_callback (Widget * w, widget_msg_t msg, int parm)
|
||||
{
|
||||
char *cwd;
|
||||
|
||||
cwd = strip_password (vfs_path_to_str (panel->cwd_vpath), 1);
|
||||
cwd = vfs_path_to_str_flags (panel->cwd_vpath, 0, VPF_STRIP_PASSWORD);
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot chdir to \"%s\"\n%s"),
|
||||
cwd, unix_error_string (errno));
|
||||
g_free (cwd);
|
||||
@ -4430,11 +4412,12 @@ update_panels (panel_update_flags_t flags, const char *current_file)
|
||||
void
|
||||
directory_history_add (struct WPanel *panel, const char *dir)
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
char *tmp;
|
||||
|
||||
tmp = g_strdup (dir);
|
||||
strip_password (tmp, 1);
|
||||
|
||||
vpath = vfs_path_from_str (dir);
|
||||
tmp = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_PASSWORD);
|
||||
vfs_path_free (vpath);
|
||||
panel->dir_history = list_append_unique (panel->dir_history, tmp);
|
||||
}
|
||||
|
||||
|
13
src/main.c
13
src/main.c
@ -356,20 +356,17 @@ update_xterm_title_path (void)
|
||||
{
|
||||
/* TODO: share code with midnight_get_title () */
|
||||
|
||||
const char *path;
|
||||
char *path;
|
||||
char host[BUF_TINY];
|
||||
char *p;
|
||||
struct passwd *pw = NULL;
|
||||
char *login = NULL;
|
||||
int res = 0;
|
||||
|
||||
if (mc_global.tty.xterm_flag && xterm_title)
|
||||
{
|
||||
char *path_str;
|
||||
if (!(mc_global.tty.xterm_flag && xterm_title))
|
||||
return;
|
||||
|
||||
path_str = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
path = strip_home_and_password (path_str);
|
||||
g_free (path_str);
|
||||
path = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD);
|
||||
res = gethostname (host, sizeof (host));
|
||||
if (res)
|
||||
{ /* On success, res = 0 */
|
||||
@ -395,7 +392,7 @@ update_xterm_title_path (void)
|
||||
if (!mc_global.tty.alternate_plus_minus)
|
||||
numeric_keypad_mode ();
|
||||
(void) fflush (stdout);
|
||||
}
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1170,13 +1170,11 @@ subshell_name_quote (const char *s)
|
||||
void
|
||||
do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean reset_prompt)
|
||||
{
|
||||
char *pcwd, *cwd_str;
|
||||
char *pcwd;
|
||||
char *temp;
|
||||
char *directory;
|
||||
|
||||
cwd_str = vfs_path_to_str (current_panel->cwd_vpath);
|
||||
pcwd = vfs_translate_path_n (cwd_str);
|
||||
g_free (cwd_str);
|
||||
pcwd = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_RECODE);
|
||||
|
||||
if (!(subshell_state == INACTIVE && strcmp (subshell_cwd, pcwd) != 0))
|
||||
{
|
||||
@ -1250,9 +1248,11 @@ do_subshell_chdir (const vfs_path_t * vpath, gboolean update_prompt, gboolean re
|
||||
bPathNotEq = strcmp (p_subshell_cwd, p_current_panel_cwd);
|
||||
}
|
||||
|
||||
if (bPathNotEq && strcmp (pcwd, "."))
|
||||
if (bPathNotEq && strcmp (pcwd, ".") != 0)
|
||||
{
|
||||
char *cwd = strip_password (g_strdup (pcwd), 1);
|
||||
char *cwd;
|
||||
|
||||
cwd = vfs_path_to_str_flags (current_panel->cwd_vpath, 0, VPF_STRIP_PASSWORD);
|
||||
vfs_print_message (_("Warning: Cannot change to %s.\n"), cwd);
|
||||
g_free (cwd);
|
||||
}
|
||||
|
@ -185,6 +185,9 @@ START_TEST(test_path_to_str_flags)
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD);
|
||||
fail_unless (strcmp ("~/test1://user@host.name/#enc:KOI8-R/теÑ<C2B5>товый/путь", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
g_free (str_path);
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD | VPF_HIDE_CHARSET);
|
||||
fail_unless (strcmp ("~/test1://user@host.name/тестовый/путь", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
g_free (str_path);
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_RECODE);
|
||||
fail_unless (strcmp ("~/test1://user:passwd@host.name/ÔÅÓÔÏ×ÙÊ/ÐÕÔØ", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
g_free (str_path);
|
||||
|
Loading…
Reference in New Issue
Block a user