Block invalid file names when renaming torrent content

Relevant issues: #22426, #21899,#16906,#16834, #16271, #11276, #9085, #11340, #14728, #20412, #20337, #17049, #17752, #17469, #15378, #15227, #14908.
PR #23060.

---------

Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
cocopaw
2025-09-20 16:42:30 +10:00
committed by GitHub
parent 753fb80e9b
commit 9696c99dbd
4 changed files with 72 additions and 1 deletions

View File

@@ -299,9 +299,16 @@ bool TorrentContentModel::setData(const QModelIndex &index, const QVariant &valu
case TorrentContentModelItem::COL_NAME:
{
const QString currentName = item->name();
const QString newName = value.toString();
const QString newName = value.toString().trimmed();
if (currentName != newName)
{
if (!Utils::Fs::isValidName(newName))
{
emit renameFailed(tr("The name is invalid: \"%1\"").arg(newName));
return false;
}
try
{
const Path parentPath = getItemPath(index.parent());