fix: parse install hook lines with proper quote handling#1695
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces trim_left and trim_right string helper functions, along with their respective unit tests. It also refactors the install hook parsing logic by introducing a robust parseInstallHookCommandLine function that correctly handles quoted commands and trailing whitespaces, accompanied by comprehensive unit tests. The reviewer suggested optimizing the hook parsing loop by breaking early once a matching command is found, which avoids redundant parsing attempts for other prefixes on the same line.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
Signed-off-by: reddevillg <reddevillg@gmail.com>
deepin pr auto review★ 总体评分:99分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 command.remove_prefix(1);
auto suffix = common::strings::trim_right(command, WHITESPACE_CHARS);
if (suffix.empty() || suffix.back() != quote) {
- return LINGLONG_ERR("Invalid install hook command: unterminated quoted command");
+ if (!suffix.empty()) {
+ return LINGLONG_ERR("Invalid install hook command: trailing characters after quoted command");
+ }
+ return LINGLONG_ERR("Invalid install hook command: unterminated quoted command");
}
suffix.remove_suffix(1); |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengbo11, reddevillg 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 |
No description provided.