From 80bb19701cf7df358949e1c717b0774e754acb10 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 3 Aug 2023 12:38:56 +0800 Subject: [PATCH] Ensure file name is valid when exporting torrents Closes #19275. Closes #19329. --- src/gui/transferlistwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 910ee4238..71c1e117e 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -818,7 +818,8 @@ void TransferListWidget::exportTorrent() bool hasError = false; for (const BitTorrent::Torrent *torrent : torrents) { - const Path filePath = savePath / Path(torrent->name() + u".torrent"); + const QString validName = Utils::Fs::toValidFileName(torrent->name(), u"_"_s); + const Path filePath = savePath / Path(validName + u".torrent"); if (filePath.exists()) { LogMsg(errorMsg.arg(torrent->name(), filePath.toString(), tr("A file with the same name already exists")) , Log::WARNING);