Merge pull request #3573 from RedSoxFan/ipc-newlines

IPC_COMMAND: split on newline
This commit is contained in:
Drew DeVault 2019-02-05 14:39:10 +01:00 committed by GitHub
commit a6363d1206
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -595,6 +595,16 @@ void ipc_client_handle_command(struct ipc_client *client) {
switch (client->current_command) { switch (client->current_command) {
case IPC_COMMAND: case IPC_COMMAND:
{ {
char *line = strtok(buf, "\n");
while (line) {
size_t line_length = strlen(line);
if (line + line_length >= buf + client->payload_length) {
break;
}
line[line_length] = ';';
line = strtok(NULL, "\n");
}
list_t *res_list = execute_command(buf, NULL, NULL); list_t *res_list = execute_command(buf, NULL, NULL);
transaction_commit_dirty(); transaction_commit_dirty();
char *json = cmd_results_to_json(res_list); char *json = cmd_results_to_json(res_list);