feat: add safe preview and controlled save for files containing NUL bytes#487
Closed
wyu71 wants to merge 1 commit into
Closed
feat: add safe preview and controlled save for files containing NUL bytes#487wyu71 wants to merge 1 commit into
wyu71 wants to merge 1 commit into
Conversation
…ytes When a file contains \x00 NUL bytes, the editor now 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. Key changes: - FileLoadThread: detect NUL bytes at raw byte level, escape to \00 - EditWrapper: preview state fields, read-only toggle, Edit Anyway, exit-preview on successful save - WarningNotices: add "Edit Anyway" button and signal - Window: unified confirmInvalidCharSave dialog, Save As same-path rejection, backup short-circuit for preview mode - CSyntaxHighlighter: \00 highlight (red background, white text) - Translations: new messages for en, zh_CN, zh_HK, zh_TW Task: https://pms.uniontech.com/task-view-392417.html Multica Issue: https://agent-dev.uniontech.com/issues/14dc6e9a-d392-4a6a-b8a9-f295ea204c96
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wyu71 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 |
Member
|
Superseded by #489 (created under the correct GitHub account dengzhongyuan365-dev). Closing this PR as it was created under the wrong account (wyu71). |
Contributor
Author
|
Superseded by #489 (created under the correct GitHub account dengzhongyuan365-dev). This PR was created under the wrong account (wyu71) and should be closed. |
Contributor
Author
|
Superseded by #489. Created under wrong account, closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 deepin-editor 实现"含无效字符 NUL 文件的安全预览与受控保存"功能。
当文件包含
\x00NUL 字节时,编辑器进入只读预览模式,将 NUL 显示为可见文本\00,并通过明确确认流程控制编辑和保存,避免用户误覆盖原文件造成不可逆损坏。主要改动
FileLoadThread\00EditWrapperWarningNoticesWindowconfirmInvalidCharSave三按钮确认弹窗(Don't Save / Save As / Save Anyway),Ctrl+S 与关闭 Tab 共用同一入口;预览模式拒绝同路径 Save As;备份短路CSyntaxHighlighter\00高亮(红色背景 + 白色文字)验收标准
hello\00world,默认只读,警告条 + Edit Anyway,\00高亮,原文件不变*测试
已通过人工功能验证(US-1 至 US-7)及 AI 代码审查。
关联