Skip to content

fix: AppGroup::parseGroupId off-by-one slice error (mid(len+1) → mid(len)) - #1713

Open
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:agent/dde-pl/218abfc9
Open

fix: AppGroup::parseGroupId off-by-one slice error (mid(len+1) → mid(len))#1713
MyLeeJiEun wants to merge 1 commit into
linuxdeepin:masterfrom
MyLeeJiEun:agent/dde-pl/218abfc9

Conversation

@MyLeeJiEun

@MyLeeJiEun MyLeeJiEun commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

修复内容

AppGroup::parseGroupId 存在 off-by-one 切片错误:mid(len + 1) 应为 mid(len)

根因

"internal/folder/" 长度为 16 字符(下标 0–15),folder 号从下标 16 开始。mid(len + 1) = mid(17) 多跳一位,跳过了 folder 号的首位数字:

输入 mid(17) 旧(缺陷) mid(16) 新(修复)
internal/folder/0 "" → 0(偶然正确) "0" → 0 ✅
internal/folder/5 "" → 0 ❌ "5" → 5 ✅
internal/folder/123 "23" → 23 ❌ "123" → 123 ✅

变更

仅 1 行改动(applets/dde-apps/appgroup.cpp:64):

-    return QStringView{id}.mid(len + 1).toInt();
+    return QStringView{id}.mid(len).toInt();

调用点

parseGroupId 共 2 处调用,均已确认输入为合法 "internal/folder/..." 形式:

  • appgroup.cpp:23 构造函数:groupId 来自 groupIdFromNumber()"internal/folder/N"
  • appgroupmanager.cpp:185 拖拽落点:前置 AppGroup::idIsFolder(dropId) 守卫

无回归风险,变更最小且外科手术式。

Closes: DDE-143

Summary by Sourcery

Bug Fixes:

  • Correct folder group ID parsing to preserve the first digit of valid internal folder identifiers.

…len))

"internal/folder/" is 16 characters (indices 0-15), so the folder
number starts at index 16. mid(len + 1) = mid(17) skipped the first
digit, causing all non-zero folder IDs to parse incorrectly (e.g.
"internal/folder/123" → 23 instead of 123). Folder 0 was incidentally
correct because mid(17) yielded an empty string → toInt() = 0.

Change mid(len + 1) to mid(len) so slicing starts at the correct
position.

Closes: DDE-143
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MyLeeJiEun

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes AppGroup::parseGroupId by removing the one-character overrun in the prefix slice, ensuring folder IDs such as 5 and 123 are parsed completely while retaining existing behavior for 0.

File-Level Changes

Change Details Files
Correct the folder-number substring offset so parsing starts immediately after the internal/folder/ prefix.
  • Replace mid(len + 1) with mid(len) to preserve the first digit of the folder ID.
  • Verify the correction against single- and multi-digit folder IDs and the two guarded call sites.
applets/dde-apps/appgroup.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

Hi @MyLeeJiEun. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants