files: before sending data to an external command, decode LF back to NUL
(There is no need to recode the NULs back to LFs because the sending of the data happens in a separate process, which then simply disappears.) This fixes https://savannah.gnu.org/bugs/?63106. Bug existed since version 2.9.8, since filtering a buffer or a region through an external command was introduced.
This commit is contained in:
parent
8d7b716ea7
commit
1dc2a75cb6
11
src/files.c
11
src/files.c
@ -988,7 +988,16 @@ void send_data(const linestruct *line, int fd)
|
|||||||
|
|
||||||
/* Send each line, except a final empty line. */
|
/* Send each line, except a final empty line. */
|
||||||
while (line != NULL && (line->next != NULL || line->data[0] != '\0')) {
|
while (line != NULL && (line->next != NULL || line->data[0] != '\0')) {
|
||||||
fprintf(tube, "%s%s", line->data, line->next == NULL ? "" : "\n");
|
size_t length = strlen(line->data);
|
||||||
|
|
||||||
|
recode_LF_to_NUL(line->data);
|
||||||
|
|
||||||
|
if (fwrite(line->data, sizeof(char), length, tube) < length)
|
||||||
|
exit(5);
|
||||||
|
|
||||||
|
if (line->next && putc('\n', tube) == EOF)
|
||||||
|
exit(6);
|
||||||
|
|
||||||
line = line->next;
|
line = line->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user