fix: issue 1138 windows encoding (#1139)

* fix(windows): use utf-8 for text file operations

* fix(windows): normalize sandbox path masking

* fix(windows): preserve utf-8 handling after backend split
This commit is contained in:
-Astraia-
2026-03-16 16:53:12 +08:00
committed by GitHub
parent 76803b826f
commit 191b60a326
15 changed files with 116 additions and 24 deletions

View File

@@ -58,3 +58,31 @@ unsupported: true
assert valid is False
assert "unsupported" in message
assert skill_name is None
def test_validate_skill_frontmatter_reads_utf8_on_windows_locale(tmp_path, monkeypatch) -> None:
skill_dir = tmp_path / "demo-skill"
_write_skill(
skill_dir,
"""---
name: demo-skill
description: "Curly quotes: \u201cutf8\u201d"
---
# Demo Skill
""",
)
original_read_text = Path.read_text
def read_text_with_gbk_default(self, *args, **kwargs):
kwargs.setdefault("encoding", "gbk")
return original_read_text(self, *args, **kwargs)
monkeypatch.setattr(Path, "read_text", read_text_with_gbk_default)
valid, message, skill_name = VALIDATE_SKILL_FRONTMATTER(skill_dir)
assert valid is True
assert message == "Skill is valid!"
assert skill_name == "demo-skill"