From ee89ee5972bc9675d52d6a9c457c781a44205587 Mon Sep 17 00:00:00 2001 From: liuwenhuan Date: Mon, 9 Nov 2026 07:55:43 +0800 Subject: [PATCH] fix: recognise the unrar 7 "use current password?" prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. When the file data of a RAR archive is encrypted but the headers are not, unrar asks for the password of the first file and then, for each following file, whether to reuse it. unrar 7 prints " - use current password? [Y]es, [N]o, [A]ll" (no space before '?'); unrar 5/6 printed "use current password ? [Y]es, [N]o, [A]ll". 2. isMultiPasswordPrompt() only matched the old text, so with unrar 7 the prompt was never answered: unrar waited on the pty and the progress page stayed at 1 % for ever. 3. Accept both texts; add test cases with the unrar 7 wording. Log: Fix extraction of encrypted RAR archives hanging at 1 % with unrar 7. Influence: 1. With unrar 7.x, extract a RAR5 archive of several files created with "rar a -p" (headers not encrypted), single and multi-volume; enter the password once; extraction completes. 2. The unrar 5/6 prompt is still recognised. fix: 识别 unrar 7 的 "use current password?" 提示 1. RAR 包只加密文件数据、不加密文件头时,unrar 先询问第一个文件的密码, 之后对每个文件询问是否沿用当前密码。unrar 7 的提示是 "<文件> - use current password? [Y]es, [N]o, [A]ll"(问号前没有空格), unrar 5/6 是 "use current password ? [Y]es, [N]o, [A]ll"。 2. isMultiPasswordPrompt() 只匹配旧写法,unrar 7 下这个提示得不到回答, unrar 一直在 pty 上等待,进度页面停在 1%。 3. 两种写法都识别,并补充 unrar 7 写法的测试用例。 Log: 修复 unrar 7 下解压加密 RAR 包卡在 1% 的问题。 Influence: 1. 使用 unrar 7.x 解压 "rar a -p<密码>" 创建的多文件 RAR5 包(文件头不加密), 含分卷;只输入一次密码,解压完成。 2. unrar 5/6 的提示仍能识别。 --- 3rdparty/clirarplugin/clirarplugin.cpp | 4 +++- tests/UnitTest/3rdparty/clirarplugin/ut_clirarplugin.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/3rdparty/clirarplugin/clirarplugin.cpp b/3rdparty/clirarplugin/clirarplugin.cpp index 61f4ccec7..67ae1d522 100644 --- a/3rdparty/clirarplugin/clirarplugin.cpp +++ b/3rdparty/clirarplugin/clirarplugin.cpp @@ -148,7 +148,9 @@ bool CliRarPlugin::isFileExistsFileName(const QString &line) bool CliRarPlugin::isMultiPasswordPrompt(const QString &line) { - return line.contains("use current password ? [Y]es, [N]o, [A]ll"); + // unrar 5/6 print "use current password ? [Y]es, [N]o, [A]ll"; unrar 7 dropped the space before '?' + return line.contains(QLatin1String("use current password ? [Y]es, [N]o, [A]ll")) + || line.contains(QLatin1String("use current password? [Y]es, [N]o, [A]ll")); } bool CliRarPlugin::isOpenFileFailed(const QString &line) diff --git a/tests/UnitTest/3rdparty/clirarplugin/ut_clirarplugin.cpp b/tests/UnitTest/3rdparty/clirarplugin/ut_clirarplugin.cpp index b1104c304..5b9aaf1d3 100644 --- a/tests/UnitTest/3rdparty/clirarplugin/ut_clirarplugin.cpp +++ b/tests/UnitTest/3rdparty/clirarplugin/ut_clirarplugin.cpp @@ -179,6 +179,9 @@ TEST_F(UT_CliRarPlugin, test_isFileExistsFileName) TEST_F(UT_CliRarPlugin, test_isMultiPasswordPrompt) { EXPECT_EQ(m_tester->isMultiPasswordPrompt("use current password ? [Y]es, [N]o, [A]ll"), true); + // unrar 7.x wording (no space before '?') + EXPECT_EQ(m_tester->isMultiPasswordPrompt("dir/b.dll - use current password? [Y]es, [N]o, [A]ll "), true); + EXPECT_EQ(m_tester->isMultiPasswordPrompt("Extracting dir/a.dll OK "), false); } TEST_F(UT_CliRarPlugin, test_isOpenFileFailed) @@ -315,6 +318,7 @@ TEST_F(UT_CliRarPlugin, test_handleLine_006) Stub stub; stub.set(ADDR(CliInterface, writeToProcess), cliInterface_writeToProcess_stub); EXPECT_EQ(m_tester->handleLine("use current password ? [Y]es, [N]o, [A]ll", WT_Extract), true); + EXPECT_EQ(m_tester->handleLine("dir/b.dll - use current password? [Y]es, [N]o, [A]ll ", WT_Extract), true); } TEST_F(UT_CliRarPlugin, test_handleLine_007)