diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2017-06-23 17:58:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-23 17:58:08 +0200 |
commit | 1ff2f61f090a61f3bdf0bdee5c52a7907d56acfd (patch) | |
tree | a591179d1aa27cf508d4f3348d164974c8e7adb4 | |
parent | b483ec5faa76dc38f2e338f89c54a6e4cd06c764 (diff) | |
parent | bbf8b860747c13a478657b9070c191735d35e00a (diff) | |
download | irssi-1ff2f61f090a61f3bdf0bdee5c52a7907d56acfd.zip |
Merge pull request #723 from ailin-nemui/odd_expand_escapes
fix weird n-fold unescaping in expand_escapes
-rw-r--r-- | src/fe-common/core/chat-completion.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c index 1f00feaf..97cd0565 100644 --- a/src/fe-common/core/chat-completion.c +++ b/src/fe-common/core/chat-completion.c @@ -1011,13 +1011,17 @@ static void sig_complete_target(GList **list, WINDOW_REC *window, } } +static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item); + /* expand \n, \t and \\ */ static char *expand_escapes(const char *line, SERVER_REC *server, WI_ITEM_REC *item) { char *ptr, *ret; - int chr; + const char *prev; + int chr; + prev = line; ret = ptr = g_malloc(strlen(line)+1); for (; *line != '\0'; line++) { if (*line != '\\') { @@ -1036,9 +1040,11 @@ static char *expand_escapes(const char *line, SERVER_REC *server, /* newline .. we need to send another "send text" event to handle it (or actually the text before the newline..) */ - if (ret != ptr) { - *ptr = '\0'; - signal_emit("send text", 3, ret, server, item); + if (prev != line) { + char *prev_line = g_strndup(prev, (line - prev) - 1); + event_text(prev_line, server, item); + g_free(prev_line); + prev = line + 1; ptr = ret; } } else if (chr != -1) { |