Commit 6cefb9f2 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

in do_browser(), display an error messsage on the statusbar if we try to

move up from "/" via the "Go to Directory" prompt, for consistency


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3699 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 15 additions and 1 deletion
+15 -1
...@@ -16,6 +16,9 @@ CVS code - ...@@ -16,6 +16,9 @@ CVS code -
- Remove unneeded call to blank_edit(). (DLR) - Remove unneeded call to blank_edit(). (DLR)
- After entering "..", select the directory we were in before - After entering "..", select the directory we were in before
instead of the first filename in the list, as Pico does. (DLR) instead of the first filename in the list, as Pico does. (DLR)
- Display an error messsage on the statusbar if we try to move
up from "/" via the "Go to Directory" prompt, for consistency.
(DLR)
browser_refresh() browser_refresh()
- Simplify. (DLR) - Simplify. (DLR)
- Fix problems where translated versions of "(dir)" could be - Fix problems where translated versions of "(dir)" could be
......
...@@ -107,7 +107,7 @@ char *do_browser(char *path, DIR *dir) ...@@ -107,7 +107,7 @@ char *do_browser(char *path, DIR *dir)
int i; int i;
size_t fileline; size_t fileline;
char *new_path; char *new_path;
/* Used by the "Go To Directory" prompt. */ size_t new_path_len;
/* Compute the line number we're on now, so that we don't divide /* Compute the line number we're on now, so that we don't divide
* by zero. */ * by zero. */
...@@ -243,6 +243,7 @@ char *do_browser(char *path, DIR *dir) ...@@ -243,6 +243,7 @@ char *do_browser(char *path, DIR *dir)
ans = mallocstrcpy(ans, ""); ans = mallocstrcpy(ans, "");
new_path = real_dir_from_tilde(answer); new_path = real_dir_from_tilde(answer);
new_path_len = strlen(new_path) + 1;
if (new_path[0] != '/') { if (new_path[0] != '/') {
new_path = charealloc(new_path, strlen(path) + new_path = charealloc(new_path, strlen(path) +
...@@ -250,6 +251,16 @@ char *do_browser(char *path, DIR *dir) ...@@ -250,6 +251,16 @@ char *do_browser(char *path, DIR *dir)
sprintf(new_path, "%s%s", path, answer); sprintf(new_path, "%s%s", path, answer);
} }
if (new_path[new_path_len - 1] == '/')
null_at(&new_path, new_path_len - 1);
/* We can't move up from "/". */
if (strcmp(new_path, "/..") == 0) {
statusbar(_("Can't move up a directory"));
beep();
break;
}
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
if (check_operating_dir(new_path, FALSE)) { if (check_operating_dir(new_path, FALSE)) {
statusbar( statusbar(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment