mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-04 22:52:33 -06:00
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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user