1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 05:16:38 +02:00

xfer: replace directory separator in remote nick by underscore in download filename

This commit is contained in:
aizu-m
2026-06-02 12:31:10 +05:30
committed by Sébastien Helleu
parent d15ce789a0
commit 1438255a87
2 changed files with 12 additions and 3 deletions
+1
View File
@@ -13,6 +13,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
- api: fix infinite loop in function string_replace when the search string is empty
- irc: limit size of data received from the server to prevent memory exhaustion
- relay: limit size of received websocket frame and HTTP body to prevent memory exhaustion
- xfer: replace directory separator in remote nick by underscore in download filename to prevent writing the file outside the download directory
## Version 4.9.1 (2026-05-31)
+11 -3
View File
@@ -251,7 +251,7 @@ xfer_file_find_suffix (struct t_xfer *xfer)
void
xfer_file_find_filename (struct t_xfer *xfer)
{
char *dir_separator, *path;
char *dir_separator, *path, *nick;
struct t_hashtable *options;
if (!XFER_IS_FILE(xfer->type))
@@ -287,12 +287,20 @@ xfer_file_find_filename (struct t_xfer *xfer)
{
strcat (xfer->local_filename, dir_separator);
}
free (dir_separator);
if (weechat_config_boolean (xfer_config_file_use_nick_in_filename))
{
strcat (xfer->local_filename, xfer->remote_nick);
/*
* the remote nick comes from the server and can contain a directory
* separator: replace it so the nick cannot make the file be written
* outside the download directory
*/
nick = (dir_separator) ?
weechat_string_replace (xfer->remote_nick, dir_separator, "_") : NULL;
strcat (xfer->local_filename, (nick) ? nick : xfer->remote_nick);
free (nick);
strcat (xfer->local_filename, ".");
}
free (dir_separator);
strcat (xfer->local_filename, xfer->filename);
free (path);