fix(search): decode base64 keywords before updating search#622
Conversation
ac522fa to
5c3f703
Compare
- Updated the search functionality to decode base64 encoded keywords before passing them to the search update method. This ensures proper handling of encoded search terms in the application. bug: https://pms.uniontech.com/bug-view-362267.html
5c3f703 to
7d653eb
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev 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 |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev 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 |
deepin pr auto review你好!我是CodeGeeX,你的智能编程助手。我已经仔细审查了你提供的 Git Diff 记录。 本次代码变更主要做了两件事:一是更新了版权年份至 2026;二是在处理 以下是我对本次代码变更在语法逻辑、代码质量、代码性能和代码安全方面的详细审查意见及改进建议: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
🌟 改进后的代码建议针对以上问题,我为你重构了这部分代码,增加了健壮的异常处理,修复了命名规范,并移除了调试代码: // 建议将 isbase64 重命名为 isBase64,并确保其内部正则高效准确
// 示例:isBase64 = (str) => /^[A-Za-z0-9+/]+={0,2}$/.test(str);
} else if (list[1] === 'search') { // 使用严格相等 ===
// 移除 console.log,避免敏感信息泄露
let keyword = list[2];
// 使用 try-catch 包裹解码逻辑,防止非法字符串导致页面崩溃
if (this.isBase64(keyword)) { // 修正方法名小驼峰命名
try {
// 注意:请确认编码顺序!
// 如果原逻辑是先 URL 编码再 Base64 编码,则保持下面这行
keyword = decodeURIComponent(atob(keyword));
// 如果原逻辑是先 Base64 编码再 URL 编码,请替换为下面这行
// keyword = atob(decodeURIComponent(keyword));
} catch (error) {
console.error('Failed to decode search keyword:', error);
// 解码失败时,降级使用原始关键词,或者赋空值,保证程序不崩溃
keyword = list[2];
}
}
// 确保传入的 keyword 是安全的字符串
global.qtObjects.search.updateSearch(keyword);
} else {
// ...
}总结:本次改动业务逻辑上没有大问题,但缺乏异常保护是致命的,极易被恶意输入击溃。请务必加上 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
bug: https://pms.uniontech.com/bug-view-362267.html