Repository navigation
fix: move hyphen to end of regex char class - #233
wangrong1069 wants to merge 1 commit into
Conversation
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
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wangrong1069 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR fixes Qt6 password fields rejecting all input by making the shared validator regex valid under PCRE2 in both SM4 partition creation and LUKS decryption dialogs; the change is limited to regex literals and does not affect Qt5 behavior. Flow diagram for the Qt6 password validator fixflowchart LR
A[Password input dialog] --> B{Qt version}
B -->|Qt6| C[QRegularExpressionValidator]
C --> D[Valid character class with hyphen at end]
D --> E[Password input accepted]
B -->|Qt5| F[QRegExpValidator unchanged]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="application/widgets/customcontrol/passwordinputdialog.cpp" line_range="83" />
<code_context>
#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
</code_context>
<issue_to_address>
**Passwords are written to logs**
When a Qt6 user enters a password and submits an encryption or decryption operation, `Utils::executWithInputOutputCmd` logs `*inPut` verbatim at `basestruct/utils.cpp:155`; the enabled dialogs pass the entered password to that helper as cryptsetup input, so plaintext passwords are written to debug logs.
Remove or redact the input logging in `Utils::executWithInputOutputCmd`.
Also at `application/widgets/decryptdialog.cpp:70`.
</issue_to_address>| #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`~!@#$%^&*()_+=<>,.\\/ -]+$"); |
There was a problem hiding this comment.
🟡 Medium · Passwords are written to logs
When a Qt6 user enters a password and submits an encryption or decryption operation, Utils::executWithInputOutputCmd logs *inPut verbatim at basestruct/utils.cpp:155; the enabled dialogs pass the entered password to that helper as cryptsetup input, so plaintext passwords are written to debug logs.
Remove or redact the input logging in Utils::executWithInputOutputCmd.
Also at application/widgets/decryptdialog.cpp:70.
Prompt for AI agents
In `application/widgets/customcontrol/passwordinputdialog.cpp` at line 83:
**Passwords are written to logs**
When a Qt6 user enters a password and submits an encryption or decryption operation, `Utils::executWithInputOutputCmd` logs `*inPut` verbatim at `basestruct/utils.cpp:155`; the enabled dialogs pass the entered password to that helper as cryptsetup input, so plaintext passwords are written to debug logs.
Remove or redact the input logging in `Utils::executWithInputOutputCmd`.
Also at `application/widgets/decryptdialog.cpp:70`.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
| 🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['修改已正确,无需额外调整。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['正则模式在多个文件中重复,建议后续重构时考虑提取为共享常量,但不在本次提交范围内。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无性能优化建议。'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无安全加固建议,修复本身提升了输入校验的准确性。'] 💡 改进建议代码示例// passwordinputdialog.cpp & decryptdialog.cpp
// 修复后的正则表达式(连字符移至字符类末尾):
QRegularExpression regExp("^[A-Za-z0-9`~!@#$%^&*()_+=<>,.\\/ -]+$");
// 连字符 `-` 放在字符类末尾,确保被当作字面量匹配,而非范围运算符本报告由 AI 代码审查工具自动生成 |
|
TAG Bot New tag: 6.0.28 |
|
TAG Bot New tag: 6.0.29 |
|
TAG Bot New tag: 6.0.30 |
Root Cause Analysis
When creating an SM4 encrypted partition, the password input dialog rejects all keystrokes on Qt6 builds. The root cause is in the Qt6 code path of
passwordinputdialog.cppanddecryptdialog.cpp: the regex character class fragment_-+is interpreted by PCRE2 (QRegularExpression) as a descending range from_(0x5F) to+(0x2B), which is invalid. An invalid range makes the entireQRegularExpressionobject invalid, soQRegularExpressionValidatorrejects every character, leaving the password field unable to accept any input. The Qt5QRegExpengine was more lenient and did not exhibit this behavior.Fix
Move the hyphen (
-) from the_-+position to the very end of the character class (right before]), where PCRE2 treats it as a literal hyphen instead of a range operator. Applied to bothpasswordinputdialog.cpp(line 83, Qt6 branch) anddecryptdialog.cpp(line 70, Qt6 branch). The Qt5 code paths are left unchanged.Change Safety Assessment
Code Safety
Business Impact Scope
passwordinputdialog.cpp): password fields in the partition creation dialog now accept input on Qt6 builds.decryptdialog.cpp): password field in the decrypt dialog now accepts input on Qt6 builds.Verification Suggestion
Test creating an SM4 encrypted partition and typing a password (including hyphens and special characters). Test the LUKS decrypt dialog password input. Verify Qt5 builds have no behavior change.
根因分析
创建 SM4 加密分区时,密码输入对话框在 Qt6 构建下拒绝所有按键输入。根因在于
passwordinputdialog.cpp和decryptdialog.cpp的 Qt6 代码路径中,正则表达式字符类片段_-+被 PCRE2(QRegularExpression)解释为从_(0x5F) 到+(0x2B) 的降序范围,属于无效范围。无效范围导致整个QRegularExpression对象无效,QRegularExpressionValidator拒绝所有字符,密码输入框无法输入任何内容。Qt5 的QRegExp引擎对此更宽松,未出现此问题。修复方案
将连字符(
-)从_-+位置移至字符类末尾(紧邻]之前),此时 PCRE2 将其作为字面量而非范围运算符处理。同时修复passwordinputdialog.cpp(第 83 行,Qt6 分支)和decryptdialog.cpp(第 70 行,Qt6 分支)。Qt5 代码路径保持不变。改动安全评估
代码安全评估
业务影响范围
passwordinputdialog.cpp):分区创建对话框中的密码字段在 Qt6 构建下现在可以正常输入。decryptdialog.cpp):解密对话框中的密码字段在 Qt6 构建下现在可以正常输入。验证建议
测试创建 SM4 加密分区时输入密码(含连字符和特殊字符)。测试 LUKS 解密对话框的密码输入。验证 Qt5 构建下行为无变化。
Summary by Sourcery
Bug Fixes: