From 8335f50129f88f527f4aff9793733e9a014d3f40 Mon Sep 17 00:00:00 2001 From: wangrong Date: Fri, 6 Nov 2026 19:27:07 +0800 Subject: [PATCH] fix: correct regex character class in password input dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: the regex pattern in PasswordInputDialog::initUi() contained a reversed range `_-+` inside the character class; in PCRE2 (Qt6 QRegularExpression) this causes "range out of order in character class" compile failure, making QRegularExpressionValidator reject all input — the password field cannot accept any text 2. Fix: replace `_-+` with `_+` (literal characters) and move `-` to the end of the character class where it is treated as a literal; the allowed character set remains unchanged 3. Impact: password input in the SM4 encryption dialog now accepts valid characters; Qt5 (QRegExp/PCRE1) and Qt6 (QRegularExpression/PCRE2) branches are both fixed Log: fix password input dialog regex to allow typing in encryption password Influence: 1. Test password input in SM4 encryption partition dialog 2. Test password input with special characters (_, +, -, etc.) 3. Verify password confirmation flow works end-to-end fix: 修正密码输入框正则表达式字符类倒序范围 1. 根因:PasswordInputDialog::initUi() 中的正则表达式字符类内含 倒序范围 `_-+`,在 PCRE2(Qt6 QRegularExpression)下触发"range out of order in character class"编译失败,导致 QRegularExpressionValidator 拒绝所有输入——密码框无法输入任何内容 2. 方案:将 `_-+` 改为 `_+`(字面字符),并将 `-` 移至字符类末尾 使其作为字面量处理;允许的字符集保持不变 3. 影响:SM4 加密分区密码弹窗可正常输入密码;Qt5(QRegExp/PCRE1) 与 Qt6(QRegularExpression/PCRE2)两处同步修正 Log: 修复SM4加密分区密码弹窗输入框无法输入的问题 Influence: 1. 测试SM4加密分区密码弹窗输入功能 2. 测试包含特殊字符(_、+、-等)的密码输入 3. 验证密码确认流程端到端正常 PMS: BUG-309977 --- application/widgets/customcontrol/passwordinputdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/widgets/customcontrol/passwordinputdialog.cpp b/application/widgets/customcontrol/passwordinputdialog.cpp index 93a3eb1..4fbcc28 100644 --- a/application/widgets/customcontrol/passwordinputdialog.cpp +++ b/application/widgets/customcontrol/passwordinputdialog.cpp @@ -81,11 +81,11 @@ void PasswordInputDialog::initUi() // 限制中文和中文字符 #if QT_VERSION_MAJOR > 5 qCDebug(appLog) << "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 qCDebug(appLog) << "QT_VERSION_MAJOR <= 5, setting regular expression validator"; - QRegExp regExp("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\/ ]+$"); + QRegExp regExp("^[A-Za-z0-9`~!@#$%^&*()_+=<>,.\\/ -]+$"); QRegExpValidator *regExpValidator = new QRegExpValidator(regExp, this); #endif