Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/source/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2674,12 +2674,22 @@ bool MainWindow::handleArguments_RightMenu(const QStringList &listParam)
//这里使用最后一个文件夹名进行压缩,防止特殊字符压缩不成功
REG_EXP reg("^\s+|[\\:*\"'?<>|\r\n\t]");
if (strpath.mid(iIndex).indexOf(reg) != -1) {
QString compressor = strpath.split("=").last() + strSuffix;
QString folderName = strpath.split("=").last();
// 处理长文件夹名称,避免超出系统限制
if (folderName.length() + strSuffix.length() > FILE_TRUNCATION_LENGTH) {
folderName = folderName.left(FILE_TRUNCATION_LENGTH - strSuffix.length());
}
QString compressor = folderName + strSuffix;
if (compressor.indexOf(reg) != -1)
compressor.remove(reg);
Comment on lines 2683 to 2684
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Removing invalid characters after truncation may still leave an empty compressor name.

If all truncated characters are invalid, compressor may be empty. Please add a check to prevent creating an invalid archive path.

strArchivePath += QDir::separator() + compressor;
} else {
strArchivePath += strpath.mid(iIndex) + strSuffix;
QString folderName = strpath.mid(iIndex + 1); // 去掉前面的分隔符
// 处理长文件夹名称,避免超出系统限制
if (folderName.length() + strSuffix.length() > FILE_TRUNCATION_LENGTH) {
folderName = folderName.left(FILE_TRUNCATION_LENGTH - strSuffix.length());
}
strArchivePath += QDir::separator() + folderName + strSuffix;
}
}

Expand Down