Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy 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 GuideIntroduces a shared SSID decoder that retains UTF-8 behavior while falling back to GBK for invalid UTF-8 bytes, then applies it to access-point, device, and hotspot SSID paths so GBK-encoded names render correctly. Flow diagram for SSID decoding with GBK fallbackflowchart TD
RawSSID[Raw SSID bytes] --> Decode["decodeSsid(rawSsid)"]
Decode --> UTF8{UTF-8 valid?}
UTF8 -->|Yes| UTF8Result[Return UTF-8 text]
UTF8 -->|No| GBK{GBK decoder valid?}
GBK -->|Yes| GBKResult[Return GBK text]
GBK -->|No| Fallback[Return QString::fromUtf8 result]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…n save 1. Root cause: networkmanager-qt hardcodes fromUtf8() to decode SSID raw bytes, GBK-encoded SSIDs produce replacement chars causing mojibake. Additionally, the save path converts decoded SSID back via toUtf8(), mismatching the AP's original bytes and breaking auto-connect for GBK SSIDs. 2. Fix: add decodeSsid() utility in netutils with UTF-8 first and GBK fallback, replace 3 SSID decoding entry points. Add rawSsid() virtual method to AccessPointProxy to expose original SSID bytes, implement in AccessPointProxyNM and AccessPointsProxyInter. Change save path in devicemanagerrealize.cpp to use rawSsid() instead of ssid().toUtf8(), preserving original bytes (consistent with nmtui behavior). 3. Impact: UTF-8 SSIDs unchanged, GBK SSIDs now display correctly and auto-connect works, no API signature changes beyond new rawSsid() method Log: Fix garbled WiFi network names with GBK-encoded SSIDs and auto-connect failure Influence: 1. Test WiFi list display with UTF-8 encoded SSIDs 2. Test WiFi list display with GBK encoded SSIDs 3. Test WiFi auto-connect with GBK encoded SSIDs 4. Test hotspot SSID display and device SSID query fix: 修复GBK编码SSID显示乱码及保存后自动连接失败问题 1. 根因:networkmanager-qt 硬编码 fromUtf8() 解码 SSID 原始字节, GBK编码SSID产生替换字符导致乱码。保存路径通过 toUtf8() 将解码后 的SSID转回字节,与AP原始字节不匹配,导致GBK编码SSID自动连接失败。 2. 方案:在 netutils 中新增 decodeSsid() 工具函数,UTF-8优先解码 失败时回退GBK,替换3处SSID解码入口点。在 AccessPointProxy 基类 新增 rawSsid() 虚方法暴露原始SSID字节,AccessPointProxyNM 和 AccessPointsProxyInter 分别实现。保存路径改用 rawSsid() 替代 ssid().toUtf8(),保留原始字节(与 nmtui 行为一致)。 3. 影响:UTF-8编码SSID行为不变,GBK编码SSID正常显示且自动连接正常, 除新增 rawSsid() 方法外不影响API签名 Log: 修复GBK编码WiFi网络名称显示乱码及保存后自动连接失败问题 Influence: 1. 测试UTF-8编码SSID的网络列表显示 2. 测试GBK编码SSID的网络列表显示 3. 测试GBK编码SSID的自动连接 4. 测试热点SSID显示和设备SSID查询 PMS: BUG-357843
147dbeb to
6e8705f
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰,无需修改 2. 代码质量 ✅评价: 良好 ✅ 通过 潜在问题:
建议: 1.为 decodeSsid() 函数添加简要注释,说明回退策略和使用场景 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理,decodeSsid() 时间复杂度 O(n),QStringDecoder 创建开销极小,SSID 长度通常不超过 32 字节,无性能瓶颈 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 安全合规,无安全漏洞。decodeSsid() 通过 Qt 的 QStringDecoder API 安全处理编码转换,无缓冲区溢出风险;SSID 为公开网络标识符,不涉及敏感信息;rawSsid() 暴露的原始字节不包含敏感数据 💡 改进建议代码示例// src/netutils.cpp - 建议为 decodeSsid 添加注释
// src/netutils.h - 移除不必要的 include
// 移除: #include <QStringDecoder>
// 仅在 netutils.cpp 中保留该 include
/**
* 解码 SSID 原始字节
* 优先使用 UTF-8 解码,失败时回退到 GBK 编码,
* GBK 编解码器不可用时回退到 QString::fromUtf8() 结果。
* 用于修复 GBK 编码 SSID 在 UTF-8 解码时产生乱码的问题。
*/
QString decodeSsid(const QByteArray &rawSsid)
{
QStringDecoder utf8Decoder(QStringDecoder::Utf8);
QString result = utf8Decoder.decode(rawSsid);
if (!utf8Decoder.hasError())
return result;
QStringDecoder gbkDecoder("GBK");
if (gbkDecoder.isValid())
return gbkDecoder.decode(rawSsid);
return QString::fromUtf8(rawSsid);
}本报告由 AI 代码审查工具自动生成 |
|
问题不复现,中间版本已经修复了 |
Root Cause Analysis
KDE
networkmanager-qthardcodesQString::fromUtf8()to decode SSID raw bytes (accesspoint.cpp:206). Since the 802.11 standard does not mandate SSID encoding, GBK-encoded SSIDs fail UTF-8 decoding and produce Unicode replacement characters (U+FFFD), causing mojibake. Indde-network-core, three entry points (accesspointproxynm.cpp:58-60,devicemanagerrealize.cpp:397,hotspotcontrollernm.cpp:69) directly pass through or repeat thisfromUtf8()anti-pattern without GBK fallback.Fix
Added a
decodeSsid(const QByteArray &)utility function insrc/netutils.h/src/netutils.cppthat attempts UTF-8 decoding first, falls back to GBK when UTF-8 fails, and finally falls back tofromUtf8result if GBK is also unavailable. Replaced all 3 SSID decoding entry points to usedecodeSsid()instead of rawfromUtf8()/QString(QByteArray).Change Safety Assessment
Code Safety
decodeSsid()is a pure new function; UTF-8 SSIDs follow the exact same code path as before — GBK fallback only triggers when UTF-8 decoding fails.Business Impact Scope
Affected functional modules: WiFi network list display (SSID rendering), hotspot SSID display, and device SSID query. User scenarios: connecting to or viewing WiFi networks with GBK-encoded SSIDs will now display correctly instead of showing garbled characters. UTF-8-encoded SSIDs are unaffected.
Verification Suggestion
根因分析
KDE
networkmanager-qt在accesspoint.cpp:206硬编码使用QString::fromUtf8()解码 SSID 原始字节。由于 802.11 标准未规定 SSID 编码格式,GBK 编码的 SSID 无法通过 UTF-8 解码,产生 Unicode 替换字符(U+FFFD)导致乱码。在dde-network-core中,3 处入口点(accesspointproxynm.cpp:58-60、devicemanagerrealize.cpp:397、hotspotcontrollernm.cpp:69)直接透传或重复此fromUtf8()行为,无 GBK 回退。修复方案
在
src/netutils.h/src/netutils.cpp中新增decodeSsid(const QByteArray &)工具函数,优先 UTF-8 解码,失败时回退 GBK,GBK 不可用时回退fromUtf8结果。替换全部 3 处 SSID 解码入口点,使用decodeSsid()替代原始fromUtf8()/QString(QByteArray)。改动安全评估
代码安全评估
decodeSsid()为纯新增函数;UTF-8 编码 SSID 走与原来完全相同的路径——GBK 回退仅在 UTF-8 解码失败时触发。业务影响范围
受影响功能模块:WiFi 网络列表显示(SSID 渲染)、热点 SSID 显示、设备 SSID 查询。用户场景:连接或查看使用 GBK 编码 SSID 的 WiFi 网络时,名称将正常显示而非乱码。UTF-8 编码 SSID 不受影响。
验证建议
Summary by Sourcery
Fix SSID encoding handling by adding UTF-8 decoding with GBK fallback and preserving raw SSID bytes across network operations.
Bug Fixes:
Enhancements: