Skip to content

fix: show wrong password hint on RAR5 retry dialog - #471

Closed
Johnson-zs wants to merge 1 commit into
linuxdeepin:release/eaglefrom
Johnson-zs:agent/pms-bug-bot/840fcd0f
Closed

fix: show wrong password hint on RAR5 retry dialog#471
Johnson-zs wants to merge 1 commit into
linuxdeepin:release/eaglefrom
Johnson-zs:agent/pms-bug-bot/840fcd0f

Conversation

@Johnson-zs

@Johnson-zs Johnson-zs commented Aug 23, 2026

Copy link
Copy Markdown

修复 RAR5 错误密码重弹提示文案错误(PMS BUG-266113)

返工说明:本 PR 在上一轮 Review(D 级不通过)基础上返工,修复 C01 后更新同一 PR #471

问题

RAR5 解压输入错误密码后,unrar 不终止进程而是再次弹出密码框,该密码框复用首次提示文案「此文件已加密,请输入解压密码」,未区分「密码错误重试」与「首次输入」,导致用户误以为文件未加密而非密码错误。

上一轮 Review 失败原因(C01)

上一轮在 handlePassword() 入口捕获 m_eErrorType == ET_WrongPassword,但 RAR5 重入流程中调用方 clirarplugin.cpp:277 在调用 handlePassword() 之前已将 m_eErrorType 覆盖为 ET_NeedPassword,导致捕获恒为 false,修复完全无效。

修复方案(Approach A — 成员变量)

新增成员变量 m_bWrongPasswordRetry,在 isWrongPasswordMsg 的 RAR5 分支中(m_eErrorType 被覆盖前)设置为 true,在 handlePassword() 入口检查并重置。标记在 m_eErrorType 被覆盖前已持久化,不会丢失。

RAR5 错误密码完整时序(修复后):

  1. 错误密码 → isWrongPasswordMsg 匹配 → m_eErrorType = ET_WrongPasswordm_bWrongPasswordRetry = trueemit error + return true(进程未终止)
  2. unrar 再次输出密码提示 → isPasswordPrompt 匹配 → m_eErrorType = ET_NeedPassword(覆盖)→ handlePassword()
  3. 进入 handlePassword()isWrongPassword = m_bWrongPasswordRetrytrue ✓ → m_bWrongPasswordRetry = false(重置)
  4. PasswordNeededQuery(name, nullptr, true) → 显示「密码错误,请重新输入」✓

变更文件

文件 改动
archiveinterface.h 新增 m_bWrongPasswordRetry 成员变量
clirarplugin.cpp RAR5 错误密码分支设置 m_bWrongPasswordRetry = true
cliinterface.cpp handlePassword() 入口检查并重置标记,传递给 PasswordNeededQuery;更正注释(m01)
queries.h PasswordNeededQuery 构造函数新增 isWrongPassword 参数(= false 默认值)
queries.cpp execute() 根据标记选择「密码错误」或「此文件已加密」文案
translations/*.ts lupdate 同步翻译文件,新增 zh_CN 翻译(m02)

安全性

  • 向后兼容PasswordNeededQuery 新增参数有 = false 默认值,所有现有调用方(cliunarchiverpluginlibzippluginut_queries.cpp)仅传第 1 参数,无影响
  • ET_MissingVolume 豁免m_eErrorType != ET_MissingVolume 条件未改动,BUG-373669 修复保持完整
  • 多格式安全:RAR4/ZIP/7z 错误密码均通过 return false 终止进程,不重入 handlePassword(),新标记对它们无副作用
  • 标记在 handlePassword() 入口立即重置,不会跨次泄漏

建议项处理

  • [m01] ✅ 更正 cliinterface.cpp 注释,准确描述捕获机制(成员变量而非 m_eErrorType)
  • [m02] ✅ 运行 lupdate 同步所有 .ts 翻译文件,填充 zh_CN 翻译「密码错误,请重新输入」

关联

  • PMS: BUG-266113
  • 仓库基线: 6a7a7c9665b098275c0d75d1224621afb76d6908(release/eagle)
  • 上轮 Review 报告见 Issue 附件 review-471-wrong-password-hint.md

@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.

Sorry @Johnson-zs, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

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 23, 2026

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

Reviewer's Guide

Adds an explicit wrong-password indicator to the CLI archive password handling flow and wires it into the RAR5 retry dialog so the user sees a clear wrong-password hint instead of a generic encrypted-file prompt, while preserving existing behavior for other formats and prior bug fixes.

Sequence diagram for the RAR5 wrong-password retry prompt

sequenceDiagram
    participant Unrar
    participant CliInterface
    participant PasswordNeededQuery
    participant User

    Unrar->>CliInterface: handleLine(password prompt)
    CliInterface->>CliInterface: handlePassword()
    CliInterface->>CliInterface: capture m_eErrorType == ET_WrongPassword
    CliInterface->>PasswordNeededQuery: PasswordNeededQuery(name, nullptr, isWrongPassword)
    PasswordNeededQuery->>User: show Wrong password, please re-enter
    User-->>PasswordNeededQuery: enter password
    PasswordNeededQuery-->>CliInterface: query response
    CliInterface-->>Unrar: retry with password
Loading

File-Level Changes

Change Details Files
Track wrong-password state in CLI password handling and propagate it into the password query dialog.
  • Capture whether the last archive error was ET_WrongPassword at the start of CliInterface::handlePassword before resetting m_eErrorType.
  • Preserve the existing ET_MissingVolume exemption logic so earlier BUG-373669 behavior remains unchanged.
  • Pass the captured wrong-password flag into the PasswordNeededQuery constructor when emitting the password dialog.
3rdparty/interface/archiveinterface/cliinterface.cpp
Extend PasswordNeededQuery to accept and display a wrong-password hint when appropriate.
  • Add a defaulted bool isWrongPassword parameter to PasswordNeededQuery’s constructor and store it in the query’s m_data map.
  • Update PasswordNeededQuery::execute to show a "Wrong password, please re-enter" message when the flag is true, otherwise keep the existing "Encrypted file, please enter the password" text.
  • Update the PasswordNeededQuery declaration to match the new constructor signature with the default flag value so existing callers remain unchanged.
3rdparty/interface/queries.cpp
3rdparty/interface/queries.h

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

RAR5 archives do not terminate the process on wrong password — unrar
emits an error then re-prompts for the password. The re-prompted dialog
reused the generic "Encrypted file, please enter the password" text,
making it indistinguishable from a first-time prompt (PMS BUG-266113).

Root cause: in clirarplugin.cpp, the isPasswordPrompt branch overwrites
m_eErrorType to ET_NeedPassword *before* calling handlePassword(), so
capturing m_eErrorType inside handlePassword() always yields false.

Fix (Approach A): add a member variable m_bWrongPasswordRetry that is
set to true in the isWrongPasswordMsg RAR5 branch (before m_eErrorType
is overwritten) and checked + reset at the handlePassword() entry. Pass
the flag to PasswordNeededQuery to select the "Wrong password, please
re-enter" text on retry.

Also:
- Correct the misleading comment at handlePassword() entry (m01)
- Sync .ts translation files via lupdate, add zh_CN translation (m02)

Backward compatible: the new PasswordNeededQuery parameter has a default
value of false; ET_MissingVolume exemption logic (BUG-373669) unchanged.

Log: BUG-266113
@Johnson-zs
Johnson-zs force-pushed the agent/pms-bug-bot/840fcd0f branch from c2a3142 to ed15888 Compare August 23, 2026 18:59
@Johnson-zs Johnson-zs closed this Aug 24, 2026
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.

3 participants