Skip to content

fix(#266113): RAR5 wrong password shows incorrect prompt text - #470

Open
LiHua000 wants to merge 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:agent/bugfix-leader/7ddb4b59
Open

fix(#266113): RAR5 wrong password shows incorrect prompt text#470
LiHua000 wants to merge 1 commit into
linuxdeepin:release/eaglefrom
LiHua000:agent/bugfix-leader/7ddb4b59

Conversation

@LiHua000

@LiHua000 LiHua000 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Bug #266113

归档管理器压缩包解密输入错误密码提示此文件已加密(仅 RAR5)

根因

RAR5 错误密码走 clirarplugin.cpp else 分支 emit error(tr("Wrong password"),...) + return true,不终止进程。unrar 再次输出密码提示,导致 ET_WrongPassword 被覆盖为 ET_NeedPasswordET_NoErrorcliinterface.cpp:1050),错误上下文丢失。首问与重试复用同一 PasswordNeededQuery、同一写死文案「此文件已加密」(queries.cpp:379),瞬时错误提示被对话框掩盖。

对比 RAR4/7z/ZIP 均通过 return false 终止并持久显示「密码错误」,唯独 RAR5 异常。

修复方案(方向① — 最小侵入)

新增 m_bWrongPasswordRetry 标记(CliInterface 成员),在 RAR5 else 分支设为 truehandlePassword() 重弹密码框时传入 PasswordNeededQuery,据此显示「密码错误,请重新输入解压密码」而非「此文件已加密」。标记在每次 handlePassword() 后重置为 false

变更文件

  • 3rdparty/interface/queries.h — 构造函数增加 bool bWrongPassword = false 参数(默认值,向后兼容)
  • 3rdparty/interface/queries.cpp — 构造函数存储标记,execute() 据此区分提示文案
  • 3rdparty/interface/archiveinterface/cliinterface.h — 新增 m_bWrongPasswordRetry 成员
  • 3rdparty/interface/archiveinterface/cliinterface.cpphandlePassword() 传入标记并重置
  • 3rdparty/clirarplugin/clirarplugin.cpp — RAR5 else 分支设 m_bWrongPasswordRetry = true

兼容性

  • PasswordNeededQuery 新参数默认 false,现有调用与单元测试(ut_queries.cpp)无需改动。
  • 不影响 ET_MissingVolume 豁免逻辑。
  • 不影响 RAR4/ZIP/7z 密码错误处理路径。
  • 基线:6a7a7c9665b098275c0d75d1224621afb76d6908(release/eagle)

Summary by Sourcery

Correct the RAR5 wrong-password flow so retries display an explicit incorrect-password message.

Bug Fixes:

  • Show a clear wrong-password retry prompt for RAR5 archives instead of treating the retry as an initial encrypted-file password request.

Enhancements:

  • Preserve the existing password prompt behavior for first attempts and other archive formats while carrying retry state through the password query.

…dialog

RAR5 wrong password走 else 分支 emit error + return true 不终止进程,
unrar 再次输出密码提示导致 ET_WrongPassword 被覆盖为 ET_NeedPassword
→ ET_NoError,错误上下文丢失。首问与重试复用同一 PasswordNeededQuery、
同一写死文案「此文件已加密」,瞬时错误提示被对话框掩盖。

修复方向①(最小侵入):新增 m_bWrongPasswordRetry 标记,在 RAR5 else 分支
设为 true,handlePassword 重弹密码框时传入该标记,PasswordNeededQuery 据
此显示「密码错误,请重新输入解压密码」而非「此文件已加密」。标记在每次
handlePassword 后重置。

不破坏 ET_MissingVolume 豁免,不影响 RAR4/ZIP/7z 现有逻辑。
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000

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 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 @LiHua000, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Aug 23, 2026

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

Reviewer's Guide

Implements a minimal-intrusion fix so that RAR5 wrong-password retries display a dedicated "Wrong password" prompt instead of the generic "Encrypted file" prompt, by threading a retry flag from the RAR plugin to the password query dialog.

Sequence diagram for the RAR5 wrong-password retry prompt

sequenceDiagram
    participant RAR5 as CliRarPlugin
    participant CLI as CliInterface
    participant Query as PasswordNeededQuery
    actor User

    RAR5->>RAR5: handleLine(line, workStatus)
    RAR5->>CLI: m_bWrongPasswordRetry = true
    CLI->>Query: PasswordNeededQuery(name, m_bWrongPasswordRetry)
    CLI->>CLI: m_bWrongPasswordRetry = false
    CLI->>Query: waitForResponse()
    Query->>User: Display Wrong password, please re-enter the password
    User-->>Query: Enter password
    Query-->>CLI: Password response
Loading

File-Level Changes

Change Details Files
Propagate a wrong-password retry flag from the RAR5 plugin into the password dialog so it can render an explicit wrong-password message.
  • Add a m_bWrongPasswordRetry boolean member to CliInterface, initialized to false, to track whether the next password prompt is a retry after a wrong password.
  • Set m_bWrongPasswordRetry to true in the RAR5 wrong-password handling branch in CliRarPlugin::handleLine, right after emitting the wrong password error, while still returning true to allow a retry.
  • Pass m_bWrongPasswordRetry into PasswordNeededQuery when invoking handlePassword(), and immediately reset the flag to false after constructing the query so it only affects the next prompt.
3rdparty/interface/archiveinterface/cliinterface.h
3rdparty/interface/archiveinterface/cliinterface.cpp
3rdparty/clirarplugin/clirarplugin.cpp
Extend PasswordNeededQuery to accept and store the wrong-password flag, and vary the prompt text based on that flag while keeping backward compatibility.
  • Change the PasswordNeededQuery constructor signature to accept an optional bool bWrongPassword parameter with a default of false, maintaining source compatibility for existing call sites.
  • Store the bWrongPassword value into m_data["wrongPassword"] in the constructor so it is available during execution.
  • Update PasswordNeededQuery::execute() to select between the original "Encrypted file, please enter the password" text and the new "Wrong password, please re-enter the password" text based on the stored wrongPassword flag.
3rdparty/interface/queries.h
3rdparty/interface/queries.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

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.

2 participants