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.
master
Benno Schulenberg 2016-12-18 11:37:57 +01:00
parent eafae5d417
commit 0b0b812206
2 changed files with 0 additions and 18 deletions

View File

@ -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. */

View File

@ -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