diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-06-22 21:54:16 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-06-22 21:54:16 +0200 |
commit | 60b9e36ae28a8e6dd1c4922a420f7fcfd8840804 (patch) | |
tree | 66af2bb52690399d8d12e5138412ef58307246db /src | |
parent | 3d3cdf3884a3e6bb14a2c68aa1dbdd8a8aa52f70 (diff) | |
download | weechat-60b9e36ae28a8e6dd1c4922a420f7fcfd8840804.zip |
core: fix function string_match with joker in the string if multiple words matched in input string
Before fix:
string_match("script.color.text_description", "*script*color*", 0) => 0
After fix:
string_match("script.color.text_description", "*script*color*", 0) => 1
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-string.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/core/wee-string.c b/src/core/wee-string.c index 4fa39eaf0..a926c7aa3 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -654,6 +654,13 @@ string_match (const char *string, const char *mask, int case_sensitive) free (word); return 0; } + if ((!pos_word[length_word] && !pos_end[0]) + || string_match (pos_word + length_word, pos_end, + case_sensitive)) + { + free (word); + return 1; + } while (1) { pos_word2 = (case_sensitive) ? @@ -662,8 +669,16 @@ string_match (const char *string, const char *mask, int case_sensitive) if (!pos_word2) break; pos_word = pos_word2; + if ((!pos_word[length_word] && !pos_end[0]) + || string_match (pos_word + length_word, pos_end, + case_sensitive)) + { + free (word); + return 1; + } } - ptr_string = pos_word + length_word; + free (word); + return 0; } else { |