summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/trigger/trigger-config.c11
-rw-r--r--src/plugins/trigger/trigger.c10
2 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/trigger/trigger-config.c b/src/plugins/trigger/trigger-config.c
index 2f8b95643..57d84c871 100644
--- a/src/plugins/trigger/trigger-config.c
+++ b/src/plugins/trigger/trigger-config.c
@@ -310,11 +310,12 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option
"see /help eval); format is: \"/regex/replace/var\" (var "
"is the hashtable variable to replace, it is optional), "
"many regex can be separated by a space, for example: "
- "\"/regex1/replace1/var1 /regex2/replace2/var2\"; the "
- "separator \"/\" can be replaced by any char (one or more "
- "identical chars); matching groups can be used in replace: "
- "$0 to $99, $+ for last match and $.cN to replace all chars "
- "of group N by char c"),
+ "\"/regex1/replace1/var1 /regex2/replace2/var2\"; escaped "
+ "chars are interpreted in the regex (for example \"\\n\"); "
+ "the separator \"/\" can be replaced by any char (one or "
+ "more identical chars); matching groups can be used in "
+ "replace: $0 to $99, $+ for last match and $.cN to replace "
+ "all chars of group N by char c"),
NULL, 0, 0, value, NULL, 0, NULL, NULL,
&trigger_config_change_trigger_regex, NULL, NULL, NULL);
break;
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index a348db58a..ae311f068 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -494,12 +494,13 @@ trigger_regex_split (const char *str_regex,
{
const char *ptr_regex, *pos, *pos_replace, *pos_replace_end;
const char *pos_next_regex;
- char *delimiter;
+ char *delimiter, *str_regex_escaped;
int rc, index, length_delimiter;
struct t_trigger_regex *new_regex;
rc = 0;
delimiter = NULL;
+ str_regex_escaped = NULL;
if (!regex_count || !regex)
goto end;
@@ -571,13 +572,16 @@ trigger_regex_split (const char *str_regex,
pos_replace - ptr_regex);
if (!(*regex)[index].str_regex)
goto memory_error;
+ str_regex_escaped = weechat_string_convert_escaped_chars ((*regex)[index].str_regex);
+ if (!str_regex_escaped)
+ goto memory_error;
/* set regex */
(*regex)[index].regex = malloc (sizeof (*(*regex)[index].regex));
if (!(*regex)[index].regex)
goto memory_error;
if (weechat_string_regcomp ((*regex)[index].regex,
- (*regex)[index].str_regex,
+ str_regex_escaped,
REG_EXTENDED | REG_ICASE) != 0)
{
free ((*regex)[index].regex);
@@ -643,6 +647,8 @@ memory_error:
end:
if (delimiter)
free (delimiter);
+ if (str_regex_escaped)
+ free (str_regex_escaped);
if (rc < 0)
trigger_regex_free (regex_count, regex);