From 0b0b8122067d57af9819fc807e0b21e5687113a9 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 18 Dec 2016 11:37:57 +0100 Subject: [PATCH] files: don't change embedded newlines into nulls in filenames Because changing anything to a null effectively means to truncate the name. This fixes https://savannah.gnu.org/bugs/?49868 and fixes https://savannah.gnu.org/bugs/?49874. --- src/browser.c | 3 --- src/files.c | 15 --------------- 2 files changed, 18 deletions(-) diff --git a/src/browser.c b/src/browser.c index 9824a896..da7c173e 100644 --- a/src/browser.c +++ b/src/browser.c @@ -237,9 +237,6 @@ char *do_browser(char *path) continue; } - /* Convert newlines to nulls in the directory name. */ - sunder(answer); - path = free_and_assign(path, real_dir_from_tilde(answer)); /* If the given path is relative, join it with the current path. */ diff --git a/src/files.c b/src/files.c index d187301e..13cc6191 100644 --- a/src/files.c +++ b/src/files.c @@ -1173,9 +1173,6 @@ void do_insertfile(void) current_was_at_top = (openfile->edittop == openfile->fileage); } - /* Convert newlines to nulls in the given filename. */ - sunder(answer); - #ifndef NANO_TINY if (execute) { #ifndef DISABLE_MULTIBUFFER @@ -2320,15 +2317,10 @@ int do_writeout(bool exiting) #endif if (method == OVERWRITE) { - size_t answer_len = strlen(answer); bool name_exists, do_warning; char *full_answer, *full_filename; struct stat st; - /* Convert newlines to nulls, just before we get the - * full path. */ - sunder(answer); - full_answer = get_full_path(answer); full_filename = get_full_path(openfile->filename); name_exists = (stat((full_answer == NULL) ? @@ -2340,10 +2332,6 @@ int do_writeout(bool exiting) answer : full_answer, (full_filename == NULL) ? openfile->filename : full_filename) != 0); - /* Convert nulls to newlines. answer_len is the - * string's real length. */ - unsunder(answer, answer_len); - free(full_filename); free(full_answer); @@ -2399,9 +2387,6 @@ int do_writeout(bool exiting) #endif } - /* Convert newlines to nulls, just before we save the file. */ - sunder(answer); - /* Here's where we allow the selected text to be written to * a separate file. If we're using restricted mode, this * function is disabled, since it allows reading from or