in do_insertfile(), properly handle executable commands that contain
nulls git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3972 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
50d78a6f9a
commit
013613ec40
|
@ -5,6 +5,9 @@ CVS code -
|
||||||
the "Insert File" prompt to contain nulls. Changes to
|
the "Insert File" prompt to contain nulls. Changes to
|
||||||
do_statusbar_input(), do_statusbar_output(), and
|
do_statusbar_input(), do_statusbar_output(), and
|
||||||
do_statusbar_verbatim_input(). (DLR)
|
do_statusbar_verbatim_input(). (DLR)
|
||||||
|
- files.c:
|
||||||
|
do_insertfile()
|
||||||
|
- Properly handle executable commands that contain nulls. (DLR)
|
||||||
- nano.h:
|
- nano.h:
|
||||||
- Rename NANO_ALT_REPLACE_KEY to NANO_REPLACE_ALTKEY, for
|
- Rename NANO_ALT_REPLACE_KEY to NANO_REPLACE_ALTKEY, for
|
||||||
consistency. (DLR)
|
consistency. (DLR)
|
||||||
|
|
19
src/files.c
19
src/files.c
|
@ -294,8 +294,8 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
|
||||||
{
|
{
|
||||||
filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct));
|
filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct));
|
||||||
|
|
||||||
/* Convert nulls to newlines. buf_len is the string's real length
|
/* Convert nulls to newlines. buf_len is the string's real
|
||||||
* here. */
|
* length. */
|
||||||
unsunder(buf, buf_len);
|
unsunder(buf, buf_len);
|
||||||
|
|
||||||
assert(openfile->fileage != NULL && strlen(buf) == buf_len);
|
assert(openfile->fileage != NULL && strlen(buf) == buf_len);
|
||||||
|
@ -802,15 +802,25 @@ void do_insertfile(
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (execute) {
|
if (execute) {
|
||||||
|
size_t answer_len = strlen(answer);
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
if (ISSET(MULTIBUFFER))
|
if (ISSET(MULTIBUFFER))
|
||||||
/* Open a blank buffer. */
|
/* Open a blank buffer. */
|
||||||
open_buffer("");
|
open_buffer("");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Convert newlines to nulls, just before we execute a
|
||||||
|
* command. */
|
||||||
|
sunder(answer);
|
||||||
|
|
||||||
/* Save the command's output in the current buffer. */
|
/* Save the command's output in the current buffer. */
|
||||||
execute_command(answer);
|
execute_command(answer);
|
||||||
|
|
||||||
|
/* Convert nulls to newlines. answer_len is answer's
|
||||||
|
* real length. */
|
||||||
|
unsunder(answer, answer_len);
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
if (ISSET(MULTIBUFFER)) {
|
if (ISSET(MULTIBUFFER)) {
|
||||||
/* Move back to the beginning of the first line of
|
/* Move back to the beginning of the first line of
|
||||||
|
@ -1564,12 +1574,13 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
while (fileptr != NULL) {
|
while (fileptr != NULL) {
|
||||||
size_t data_len = strlen(fileptr->data), size;
|
size_t data_len = strlen(fileptr->data), size;
|
||||||
|
|
||||||
/* Newlines to nulls, just before we write to disk. */
|
/* Convert newlines to nulls, just before we write to disk. */
|
||||||
sunder(fileptr->data);
|
sunder(fileptr->data);
|
||||||
|
|
||||||
size = fwrite(fileptr->data, sizeof(char), data_len, f);
|
size = fwrite(fileptr->data, sizeof(char), data_len, f);
|
||||||
|
|
||||||
/* Nulls to newlines; data_len is the string's real length. */
|
/* Convert nulls to newlines. data_len is the string's real
|
||||||
|
* length. */
|
||||||
unsunder(fileptr->data, data_len);
|
unsunder(fileptr->data, data_len);
|
||||||
|
|
||||||
if (size < data_len) {
|
if (size < data_len) {
|
||||||
|
|
Loading…
Reference in New Issue