Skip to content

Commit

Permalink
Merge branch 'fix-gl-19' into 'security'
Browse files Browse the repository at this point in the history
rewrite completion code and check for direct match of separator

See merge request irssi/irssi!27
  • Loading branch information
ailin-nemui committed Jan 4, 2018
2 parents cf70fcd + 2361d4b commit 94f0cbe
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/fe-common/core/completion.c
Expand Up @@ -187,12 +187,18 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i
char *old;

old = linestart;
linestart = *linestart == '\0' ?
g_strdup(word) :
g_strdup_printf("%s%c%s",
/* do not accidentally duplicate the word separator */
line == wordstart - 1 ? "" : linestart,
old_wordstart[-1], word);
/* we want to move word into linestart */
if (*linestart == '\0') {
linestart = g_strdup(word);
} else {
GString *str = g_string_new(linestart);
if (old_wordstart[-1] != str->str[str->len - 1]) {
/* do not accidentally duplicate the word separator */
g_string_append_c(str, old_wordstart[-1]);
}
g_string_append(str, word);
linestart = g_string_free(str, FALSE);
}
g_free(old);

g_free(word);
Expand Down

0 comments on commit 94f0cbe

Please sign in to comment.