Skip to content

Conversation

@ordYang668
Copy link
Contributor

本次代码变更有以下几点:

  • 修复了文件夹复制逻辑,禁止将文件夹复制到自身或其子文件夹
  • 新增了路径校验逻辑,使操作行为与 Linux 文件系统规范 保持一致

@changeset-bot
Copy link

changeset-bot bot commented Jul 28, 2025

⚠️ No Changeset found

Latest commit: a51a27a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

@pkuhpc-review-bot pkuhpc-review-bot bot left a comment

Choose a reason for hiding this comment

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

本次代码改动主要涉及文件管理器中的复制操作验证,具体包括:

  • 在英文和中文国际化文件中添加了无效复制操作的提示信息
  • 在文件管理器组件中添加了复制操作的前置检查逻辑,防止文件夹复制到自身或子目录的情况

const toPath = join(path, x.name);

// 阻止复制到自身或子目录
if (toPath === fromPath || toPath.startsWith(fromPath + "/")) {

Choose a reason for hiding this comment

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

这里的路径比较逻辑可以更精确一些,防止路径比较时的误判。建议使用path.resolve()规范化路径后再进行比较

Suggested change
if (toPath === fromPath || toPath.startsWith(fromPath + "/")) {
if (path.resolve(toPath) === path.resolve(fromPath) || path.resolve(toPath).startsWith(path.resolve(fromPath) + path.sep)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant