summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-04-17 20:11:25 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-05-11 21:06:17 +0200
commitd7d594873b068cc18fb4e6f6e7c5eaf72bea8c52 (patch)
tree011546740911c18c776dc54cfaac69a8d847f0ed /src/plugins
parentf923524a21fe1b016d1921e576796ea588706563 (diff)
downloadweechat-d7d594873b068cc18fb4e6f6e7c5eaf72bea8c52.zip
irc: evaluate options irc.server_default.sasl_key and irc.server.xxx.sasl_key (issue #1285)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-config.c4
-rw-r--r--src/plugins/irc/irc-sasl.c21
2 files changed, 9 insertions, 16 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 50da7c3b1..1e9661546 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -1906,8 +1906,8 @@ irc_config_server_new_option (struct t_config_file *config_file,
option_name, "string",
N_("file with ECC private key for mechanism "
"\"ecdsa-nist256p-challenge\" "
- "(\"%h\" will be replaced by WeeChat home, "
- "\"~/.weechat\" by default)"),
+ "(path is evaluated, see function string_eval_path_home in "
+ "plugin API reference)"),
NULL, 0, 0,
default_value, value,
null_value_allowed,
diff --git a/src/plugins/irc/irc-sasl.c b/src/plugins/irc/irc-sasl.c
index ee864d6e4..78cc571fe 100644
--- a/src/plugins/irc/irc-sasl.c
+++ b/src/plugins/irc/irc-sasl.c
@@ -94,20 +94,17 @@ irc_sasl_mechanism_plain (const char *sasl_username, const char *sasl_password)
char *
irc_sasl_get_key_content (struct t_irc_server *server, const char *sasl_key)
{
- char *weechat_dir, *key_path1, *key_path2, *content;
+ char *key_path, *content;
if (!sasl_key)
return NULL;
content = NULL;
- weechat_dir = weechat_info_get ("weechat_dir", "");
- key_path1 = weechat_string_replace (sasl_key, "%h", weechat_dir);
- key_path2 = (key_path1) ?
- weechat_string_expand_home (key_path1) : NULL;
+ key_path = weechat_string_eval_path_home (sasl_key, NULL, NULL, NULL);
- if (key_path2)
- content = weechat_file_get_content (key_path2);
+ if (key_path)
+ content = weechat_file_get_content (key_path);
if (!content)
{
@@ -116,15 +113,11 @@ irc_sasl_get_key_content (struct t_irc_server *server, const char *sasl_key)
_("%s%s: unable to read private key in file \"%s\""),
weechat_prefix ("error"),
IRC_PLUGIN_NAME,
- (key_path2) ? key_path2 : ((key_path1) ? key_path1 : sasl_key));
+ key_path);
}
- if (weechat_dir)
- free (weechat_dir);
- if (key_path1)
- free (key_path1);
- if (key_path2)
- free (key_path2);
+ if (key_path)
+ free (key_path);
return content;
}