From cf17f38a0a43597f2004f9f308aac2a6e89b3319 Mon Sep 17 00:00:00 2001 From: wangrong Date: Wed, 28 Oct 2026 12:16:36 +0800 Subject: [PATCH] fix: move hyphen to end of regex char class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: in the Qt6 code path the password validator regex used the character class fragment _-+ which PCRE2 interprets as a descending range from _ (0x5F) to + (0x2B); an invalid range makes the whole QRegularExpression invalid, so QRegularExpressionValidator rejects every keystroke and the password field accepts no input 2. Fix: move the hyphen from the _-+ position to the very end of the character class (right before ]), where it is treated as a literal hyphen instead of a range operator; applied to both passwordinputdialog.cpp and decryptdialog.cpp Qt6 branches 3. Impact: the Qt6 password input fields for SM4 encryption and LUKS decryption now accept all intended characters including hyphens; Qt5 code path is unchanged Log: fix password input field rejecting all characters on Qt6 builds Influence: 1. Test creating an SM4 encrypted partition and typing a password 2. Test the LUKS decrypt dialog password input field 3. Verify passwords containing hyphens are accepted 4. Verify passwords with special characters still work as before fix: 将连字符移至正则表达式字符类末尾 1. 根因:Qt6 代码路径中密码校验器正则表达式使用字符类片段 _-+, PCRE2 将其解释为从 _ (0x5F) 到 + (0x2B) 的降序范围;无效范围 导致整个 QRegularExpression 无效,QRegularExpressionValidator 拒绝所有按键,密码输入框无法输入任何内容 2. 方案:将连字符从 _-+ 位置移至字符类末尾(紧邻 ] 之前),此时 连字符作为字面量而非范围运算符;同时修复 passwordinputdialog.cpp 和 decryptdialog.cpp 的 Qt6 分支 3. 影响:Qt6 下 SM4 加密和 LUKS 解密的密码输入框现在可以正常输入 所有预期字符(含连字符);Qt5 代码路径不受影响 Log: 修复 Qt6 构建下密码输入框无法输入任何字符的问题 Influence: 1. 测试创建 SM4 加密分区时输入密码 2. 测试 LUKS 解密对话框的密码输入框 3. 验证包含连字符的密码可以正常输入 4. 验证包含特殊字符的密码仍可正常使用 PMS: BUG-309977 --- application/widgets/customcontrol/passwordinputdialog.cpp | 2 +- application/widgets/decryptdialog.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/widgets/customcontrol/passwordinputdialog.cpp b/application/widgets/customcontrol/passwordinputdialog.cpp index 1b6cc74..a79b8d3 100644 --- a/application/widgets/customcontrol/passwordinputdialog.cpp +++ b/application/widgets/customcontrol/passwordinputdialog.cpp @@ -80,7 +80,7 @@ void PasswordInputDialog::initUi() // 限制中文和中文字符 #if QT_VERSION_MAJOR > 5 qDebug() << "QT_VERSION_MAJOR > 5, setting regular expression validator"; - QRegularExpression regExp("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\/ ]+$"); + QRegularExpression regExp("^[A-Za-z0-9`~!@#$%^&*()_+=<>,.\\/ -]+$"); QRegularExpressionValidator *regExpValidator = new QRegularExpressionValidator(regExp, this); #else qDebug() << "QT_VERSION_MAJOR <= 5, setting regular expression validator"; diff --git a/application/widgets/decryptdialog.cpp b/application/widgets/decryptdialog.cpp index fa4026a..4a28805 100644 --- a/application/widgets/decryptdialog.cpp +++ b/application/widgets/decryptdialog.cpp @@ -67,7 +67,7 @@ void DecryptDialog::initUi() // 限制中文和中文字符 #if QT_VERSION_MAJOR > 5 qDebug() << "[DecryptDialog] Using QRegularExpression for validator (QT_VERSION_MAJOR > 5)."; - QRegularExpression regExp("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\/ ]+$"); + QRegularExpression regExp("^[A-Za-z0-9`~!@#$%^&*()_+=<>,.\\/ -]+$"); QRegularExpressionValidator *regExpValidator = new QRegularExpressionValidator(regExp, this); #else qDebug() << "[DecryptDialog] Using QRegExp for validator (QT_VERSION_MAJOR <= 5).";