Skip to content

魔法粘贴含中文/emoji时崩溃:string->utf8 Invalid UTF-8 sequence #3880

Description

@MoonL79

错误现象

魔法粘贴含多字节 UTF-8 字符(中文、emoji)的剪贴板内容时崩溃:

;value-error ("string->utf8: Invalid UTF-8 sequence" "�")
;    (utf8-string-map char-downcase str)
;    TeXmacs/plugins/goldfish/goldfish/scheme/char.scm, line 5879

调用链:MAGIC_PASTEformat-determinelatex-recognizes?format-test?string-downcasestring->utf8 抛错。

根因

Goldfish 18.11.11(commit 7daf2e6d7)把 string-downcases7-string-downcase(按字节、不校验 UTF-8)改成 utf8-string-map char-downcase(按码点、强制 UTF-8 校验)。

format-test?tm-convert.scm:600)仍用按字节切的 substring

(== (string-downcase (substring s pos end)) what)

pos 落在多字节字符中间字节时,substring 切出非法 UTF-8 序列,string-downcase 直接抛 value-error

升级前 s7-string-downcase 按字节处理不校验,切坏的子串只是默默返回 #f,识别降级为 verbatim,粘贴流程继续。

影响

含中文/emoji 的剪贴板内容触发魔法粘贴时整个流程崩溃,用户无法完成粘贴。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions