From ef5ebc19e946efcbdf9cdf714a7d9250e6f975be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 21 Feb 2024 22:05:16 +0100 Subject: [PATCH] fset: allow filename starting with "~" in command `/fset -export` --- ChangeLog.adoc | 1 + src/plugins/fset/fset-option.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 2943e67bf..42d72d45d 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -30,6 +30,7 @@ New features:: Bug fixes:: * core: remove trailing directory separators in home directories (issue #2070) + * fset: allow filename starting with "~" in command `/fset -export` * irc: add missing tags on self action messages when capability echo-message is enabled (issue #2074) * irc: don't strip monospace color code 0x11 from incoming messages (issue #2073) * irc: fix random date displayed when a received message contains tags but no "time" (issue #2064) diff --git a/src/plugins/fset/fset-option.c b/src/plugins/fset/fset-option.c index 5b1f69bc3..b8f276555 100644 --- a/src/plugins/fset/fset-option.c +++ b/src/plugins/fset/fset-option.c @@ -1392,16 +1392,23 @@ int fset_option_export (const char *filename, int with_help) { int num_options, i; - char *line; + char *filename2, *line; FILE *file; struct t_fset_option *ptr_fset_option; struct t_hashtable *hashtable_pointers, *hashtable_extra_vars; - file = fopen (filename, "w"); - if (!file) + filename2 = weechat_string_expand_home (filename); + if (!filename2) return 0; - chmod (filename, 0600); + file = fopen (filename2, "w"); + if (!file) + { + free (filename2); + return 0; + } + + chmod (filename2, 0600); hashtable_pointers = weechat_hashtable_new ( 8, @@ -1458,6 +1465,7 @@ fset_option_export (const char *filename, int with_help) weechat_hashtable_free (hashtable_pointers); if (hashtable_extra_vars) weechat_hashtable_free (hashtable_extra_vars); + free (filename2); return 1; }