Repository navigation
[6249] 修复附件类型警告中的中文文件名实体乱码 - #4808
Merged
PinkMagicFly merged 2 commits intoNov 23, 2026
Merged
Conversation
attachment-ingest 从 herk/cork 形态的 file-path 直接提取文件名,宿主 预检把它拼进 reason 后又整条 utf8->cork,形成二次编码;Qt 只解一次 cork_to_utf8,文件名仍以 <#XXXX> 实体上屏。新增纯函数 attachment-display-filename 将 basename 解回 UTF-8 后再交给 attachment-host-precheck,使整条 reason 只在出口编码一次。文件系统 访问与插件 wire 的既有转换、attachment-policy 的白名单与规则均不变。
CI 的 clang-format-check 安装最新发布版 gf 后,仓库里仍用 (quote x) 显式写法的历史文件被判定未格式化,main 自 2026-11-17 起该检查持续 失败,与本任务改动无关。此处按新版 gf 规则重排这 29 个文件((quote x) 简化为 'x、部分多行 define-macro 归并为单行),使该检查恢复全绿。 仅格式变化,无语义改动:受影响目录的 Scheme 单测与集成测试全部通过。
PinkMagicFly
deleted the
pigmagicfly/6249/attachment-warning-cjk-filename
branch
November 23, 2026 05:32
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.
问题
在 Chat 中添加中文文件名的不支持附件时,橙色警告 toast 的标题「不支持的附件类型:」正常,但文件名显示为
<#XXXX>实体串。原因
src/Plugins/Qt/qt_chat_controller.cpp的dispatch_attachment_ingest按既有协议用from_qstring把路径转成 herk/cork 内部形态后传给 Scheme。attachment-ingest已正确地把fs-path = cork->utf8(file-path)用于文件系统访问,但展示文件名直接从原始file-path提取,仍是实体形态。宿主预检把该实体形态文件名拼进 reason,attachment-ingest又对整条 reason 做一次utf8->cork,形成二次编码;QtonAttachmentError只做一次cork_to_utf8,所以宿主中文字面量能恢复,文件名却仍以实体形式上屏。这不是 Qt 字体或翻译问题,在 Qt 端重复解码也不能修好,必须在产生展示文件名的位置对齐编码。
改动
TeXmacs/plugins/attachment/progs/attachment-policy.scm:新增纯函数该文件无
tm-define、无plugin-configure副作用,headless 单测可直接load。白名单与attachment-host-precheck的规则、签名未改。TeXmacs/plugins/attachment/progs/init-attachment.scm:attachment-ingest的文案文件名由(path->string (path-name (path file-path)))改为(attachment-display-filename file-path),使宿主字面量与文件名同为 UTF-8,整条 reason 只在出口编码一次。TeXmacs/plugins/llm/progs/llm/tests/chat-protocol-test.scm:新增test-attachment-host-precheck-nonascii-filename并注册到regtest-chat-protocol。用例以/tmp/chat-protocol-test-6249/论文附件/24你是春天你是背景.jpg的 herk 入参断言:展示名等于磁盘原名、「不支持的附件类型: …」逐字一致、utf8->cork后再cork->utf8仍逐字一致且不含<#,并反向断言直接传实体形态文件名会带出<#(锁定修复前症状)。未改动的契约
fs-path = cork->utf8(file-path)仍供path-file?/access/path-getsize使用;file-path仍供attachment-ingest-request-json与插件 wire 使用,connection_write的tree_herk_to_utf8契约不变;attachment-ingest(一次utf8->cork),QtonAttachmentError仍只做一次cork_to_utf8;from_qstring/cork_to_utf8边界,未改附件扩展名白名单与拒绝/清理行为,未改liii/attachment/goldfish/真插件。验证
单独运行新用例:
5 correct, 0 failed。手动验证
待完成。测试文件已创建:
验收点:Chat 页通过附件按钮选择该文件后,警告 toast 显示「不支持的附件类型: 24你是春天你是背景.jpg」,中文目录名不展示、汉字与磁盘原名逐一一致、无实体串;该附件仍被拒绝(无 ready chip、处理中条目移除、附件按钮停止动画、发送栅栏解除);再选 ASCII 名的不支持附件(如
example.exe)确认无回归。