Fix: [fileinfo] Can not delete file in trash.#266
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom Mar 9, 2026
Merged
Conversation
-- The path error in trash, so can not delete it. Log: fix issue Bug: https://pms.uniontech.com/bug-view-352359.htm
deepin pr auto review这段代码修改的主要目的是在构建子文件/目录的 URL 时,保留原始 URL 的 scheme(协议)和 host(主机),而不是像修改前那样强制将其转换为本地文件 URL ( 以下是对该代码修改的详细审查意见,包括语法逻辑、代码质量、代码性能和代码安全四个方面: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与建议这段代码修改在逻辑上是正确且必要的,修复了非本地文件系统支持的问题。为了进一步提高代码质量,建议进行以下改进:
改进后的代码示例(仅供参考): QUrl DEnumeratorPrivate::buildUrl(const QUrl &url, const char *fileName)
{
QString path;
const QString &dirPath = url.path();
const QString &fileStr = QString::fromUtf8(fileName); // 假设 fileName 是 UTF-8 编码
// 检查 fileName 是否包含路径分隔符,防止路径遍历
if (fileStr.contains('/') || fileStr.contains('\\')) {
qWarning() << "Invalid file name with path separators:" << fileStr;
return QUrl(); // 返回无效 URL 或进行错误处理
}
if (dirPath.isEmpty() || dirPath == "/") {
path = "/" + fileStr;
} else {
path = dirPath.endsWith('/') ? dirPath + fileStr : dirPath + "/" + fileStr;
}
// 规范化路径,去除冗余的 / 和 .
path = QDir::cleanPath(path);
// 保留原始 URL 的 scheme 和 host
QUrl nextUrl = url;
nextUrl.setPath(path);
if (url.userInfo().startsWith("originPath::")) {
// 警告:直接拼接可能存在安全风险,确保 fileName 不包含特殊字符
nextUrl.setUserInfo(url.userInfo() + "/" + fileStr);
}
return nextUrl;
}这个改进版本增加了输入验证和路径规范化,提高了代码的健壮性和安全性。 |
Johnson-zs
approved these changes
Mar 9, 2026
max-lvs
approved these changes
Mar 9, 2026
liyigang1
approved these changes
Mar 9, 2026
liyigang1
approved these changes
Mar 9, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017, Johnson-zs, liyigang1, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/forcemerge |
|
This pr force merged! (status: unstable) |
203d828
into
linuxdeepin:develop/eagle
19 of 21 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-- The path error in trash, so can not delete it.
Log: fix issue
Bug: https://pms.uniontech.com/bug-view-352359.htm