From 7e6e3cd503b3619a22709db66234cd4aeefa866f Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Sun, 25 Nov 2018 13:41:46 +0100 Subject: [PATCH 1/3] Add escape_string_escape function for expand_escapes To avoid expanding, tab completion escapes the completion list. But the escape_string function escapes too much for the expand_escapes code. Add a function that only escapes the backslashes. --- src/core/misc.c | 16 ++++++++++++++++ src/core/misc.h | 3 +++ src/fe-common/core/completion.c | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/core/misc.c b/src/core/misc.c index 27741220..bcad890d 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -757,6 +757,22 @@ char *escape_string(const char *str) return ret; } +/* Escape all '\' chars with '\' */ +char *escape_string_escape(const char *str) +{ + char *ret, *p; + + p = ret = g_malloc(strlen(str)*2+1); + while (*str != '\0') { + if (*str == '\\') + *p++ = '\\'; + *p++ = *str++; + } + *p = '\0'; + + return ret; +} + int nearest_power(int num) { int n = 1; diff --git a/src/core/misc.h b/src/core/misc.h index a46a1432..9694819f 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -93,6 +93,9 @@ char *ascii_strdown(char *str); /* Escape all '"', "'" and '\' chars with '\' */ char *escape_string(const char *str); +/* Escape all '\' chars with '\' */ +char *escape_string_escape(const char *str); + /* convert all low-ascii (<32) to ^ combinations */ char *show_lowascii(const char *str); diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index fd452e5c..02d832b0 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -256,7 +256,7 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i /* escape if the word doesn't begin with '/' and expand_escapes are turned on */ data = strchr(cmdchars, *line) == NULL && expand_escapes ? - escape_string(complist->data) : g_strdup(complist->data); + escape_string_escape(complist->data) : g_strdup(complist->data); /* word completed */ *pos = startpos + strlen(data); From 35f5e5f278444ecbbd3610292d9569d3a2f51ce1 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Sun, 25 Nov 2018 13:57:17 +0100 Subject: [PATCH 2/3] up abi --- src/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.h b/src/common.h index c8fb54df..14bfe42b 100644 --- a/src/common.h +++ b/src/common.h @@ -6,7 +6,7 @@ #define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */ #define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */ -#define IRSSI_ABI_VERSION 18 +#define IRSSI_ABI_VERSION 19 #define DEFAULT_SERVER_ADD_PORT 6667 #define DEFAULT_SERVER_ADD_TLS_PORT 6697 From 8c30367452dd592027917ce92bcebe9301d2c87a Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Tue, 8 Jan 2019 15:48:12 +0100 Subject: [PATCH 3/3] rename function --- src/core/misc.c | 2 +- src/core/misc.h | 2 +- src/fe-common/core/completion.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/misc.c b/src/core/misc.c index bcad890d..e1f199b2 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -758,7 +758,7 @@ char *escape_string(const char *str) } /* Escape all '\' chars with '\' */ -char *escape_string_escape(const char *str) +char *escape_string_backslashes(const char *str) { char *ret, *p; diff --git a/src/core/misc.h b/src/core/misc.h index 9694819f..1545f7a2 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -94,7 +94,7 @@ char *ascii_strdown(char *str); char *escape_string(const char *str); /* Escape all '\' chars with '\' */ -char *escape_string_escape(const char *str); +char *escape_string_backslashes(const char *str); /* convert all low-ascii (<32) to ^ combinations */ char *show_lowascii(const char *str); diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 02d832b0..8a986a28 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -256,7 +256,7 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i /* escape if the word doesn't begin with '/' and expand_escapes are turned on */ data = strchr(cmdchars, *line) == NULL && expand_escapes ? - escape_string_escape(complist->data) : g_strdup(complist->data); + escape_string_backslashes(complist->data) : g_strdup(complist->data); /* word completed */ *pos = startpos + strlen(data);