feat: add safe preview and controlled save for files containing NUL bytes#490
Conversation
There was a problem hiding this comment.
Sorry @dengzhongyuan365-dev, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
204f59d to
a2b92dd
Compare
…ytes Cherry-pick of PR linuxdeepin#489 (merge commit b5df59d) from master to release/eagle. Conflicts resolved preferring release/eagle base while preserving all NUL safety preview functionality. When a file contains \x00 NUL bytes, the editor enters a read-only preview mode that displays NUL as visible text \00 with red highlight, shows a warning bar with an "Edit Anyway" button, and enforces a three-button confirmation dialog (Don't Save / Save As / Save Anyway) for both Ctrl+S and close-tab flows. Save As to the original path is rejected in preview mode. Auto-backup is short-circuited during preview to prevent persisting unsaved preview edits across sessions. PMS: bug-371363 Multica Issue: https://agent-dev.uniontech.com/issues/14dc6e9a-d392-4a6a-b8a9-f295ea204c96
a2b92dd to
234a574
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // src/common/fileloadthread.cpp
// 建议抽取公共替换逻辑
inline QByteArray replaceNulBytes(const QByteArray &data) {
if (data.contains('\x00')) {
QByteArray replacedData = data;
replacedData.replace('\x00', "\\00");
return replacedData;
}
return data;
}
void FileLoadThread::run()
{
// ... 前置逻辑
QString textEncode = QString::fromLocal8Bit(encode);
if (textEncode.contains("ASCII", Qt::CaseInsensitive) || textEncode.contains("UTF-8", Qt::CaseInsensitive)) {
emit sigPreProcess(encode, replaceNulBytes(indata));
} else {
QByteArray outHeadData;
DetectCode::ChangeFileEncodingFormat(indata, outHeadData, textEncode, QString("UTF-8"));
emit sigPreProcess(encode, replaceNulBytes(outHeadData));
}
// ... 后续逻辑
} |
|
Auto-dispatch review request from Multica Issue V-310. This PR syncs the NUL safe-preview feature (already merged to Reviewers requested:
Context:
Thanks! |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
9735678
into
linuxdeepin:release/eagle
概述
将 PR #489(已合入 master)的 NUL 安全预览与受控保存功能同步到
release/eagle分支。同步说明
release/eagleHEADfa2f750release/eagle现状为准,保留 NUL 安全预览全部功能release/eagle与 master 的差异(如m_encodeHint、debug 日志、setEndlineFormatAPI 等)已按 release/eagle 既有风格适配,不影响功能语义主要改动
FileLoadThread\00EditWrapperWarningNoticesWindowconfirmInvalidCharSave三按钮确认弹窗,Ctrl+S 与关闭 Tab 共用同一入口;预览模式拒绝同路径 Save As;备份短路CSyntaxHighlighter\00高亮(红色背景 + 白色文字)关联