summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-08-22 08:56:21 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-08-22 08:56:21 +0200
commitb459dab84bcc2fa30634c083c931797e3ca6f4f6 (patch)
tree64a88f37bde2e372c2aecae66c40fd7d005f04e7
parent268aa631c6b464c0d97dce5dbe76f145a6cc5f68 (diff)
downloadweechat-b459dab84bcc2fa30634c083c931797e3ca6f4f6.zip
spell: properly skip WeeChat color codes when checking words in input (closes #1547)
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/spell/spell.c23
2 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 22d317ce3..89e392c5c 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -31,6 +31,7 @@ Bug fixes::
* core: set "notify_level" to 3 if there is a highlight in the line (issue #1529)
* core: do not add line with highlight and tag "notify_none" to hotlist (issue #1529)
* irc: send all channels in a single JOIN command when reconnecting to the server (issue #1551)
+ * spell: properly skip WeeChat color codes when checking words in input (issue #1547)
* trigger: fix recursive calls to triggers using regex (issue #1546)
* trigger: add `${tg_tags} !!- ,notify_none,` in conditions of default trigger "beep" (issue #1529)
diff --git a/src/plugins/spell/spell.c b/src/plugins/spell/spell.c
index e260f1164..905864019 100644
--- a/src/plugins/spell/spell.c
+++ b/src/plugins/spell/spell.c
@@ -656,7 +656,7 @@ spell_modifier_cb (const void *pointer, void *data,
char *misspelled_word, *old_misspelled_word, *old_suggestions, *suggestions;
char *word_and_suggestions;
const char *color_normal, *color_error, *ptr_suggestions, *pos_colon;
- int code_point, char_size;
+ int code_point, char_size, color_code_size;
int length, index_result, length_word, word_ok;
int length_color_normal, length_color_error, rc;
int input_pos, current_pos, word_start_pos, word_end_pos, word_end_pos_valid;
@@ -782,12 +782,33 @@ spell_modifier_cb (const void *pointer, void *data,
{
ptr_string_orig = NULL;
+ /* skip color codes */
+ while ((color_code_size = weechat_string_color_code_size (ptr_string)) > 0)
+ {
+ memcpy (result + index_result, ptr_string, color_code_size);
+ index_result += color_code_size;
+ ptr_string += color_code_size;
+ }
+ if (!ptr_string[0])
+ break;
+
/* find start of word: it must start with an alphanumeric char */
code_point = weechat_utf8_char_int (ptr_string);
while ((!iswalnum (code_point)) || iswspace (code_point))
{
+ /* skip color codes */
+ while ((color_code_size = weechat_string_color_code_size (ptr_string)) > 0)
+ {
+ memcpy (result + index_result, ptr_string, color_code_size);
+ index_result += color_code_size;
+ ptr_string += color_code_size;
+ }
+ if (!ptr_string[0])
+ break;
+
if (!ptr_string_orig && !iswspace (code_point))
ptr_string_orig = ptr_string;
+
char_size = weechat_utf8_char_size (ptr_string);
memcpy (result + index_result, ptr_string, char_size);
index_result += char_size;