Skip to content

Commit a10ba14

Browse files
committed
fix: preserve Windows plan paths
1 parent 4acc858 commit a10ba14

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

skills/deepmd-install/scripts/validate_plan.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import argparse
1010
import json
11+
import os
1112
import re
1213
from pathlib import (
1314
Path,
@@ -156,7 +157,8 @@ def _validate_strings(value: object, path: str, errors: list[str]) -> None:
156157
errors.append(f"{path}: unresolved shell variable is not allowed")
157158
if re.search(r"<[^<>\r\n]+>", value):
158159
errors.append(f"{path}: unresolved placeholder is not allowed")
159-
if any(character in value for character in ('"', "`", "\\")):
160+
unsafe_characters = ('"', "`") + (("\\",) if os.name != "nt" else ())
161+
if any(character in value for character in unsafe_characters):
160162
errors.append(f"{path}: unsafe shell-template character is not allowed")
161163
if any(character in value for character in ("\0", "\n", "\r")):
162164
errors.append(f"{path}: control character is not allowed")

source/tests/test_deepmd_install_skill.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,16 @@ def test_validate_plan_keeps_quoted_semicolon_as_data() -> None:
325325
assert PLAN.validate_plan(plan) == []
326326

327327

328+
def test_validate_plan_allows_windows_path_separator_on_windows(
329+
monkeypatch: pytest.MonkeyPatch,
330+
) -> None:
331+
"""Preserve Windows paths while keeping POSIX backslash escaping blocked."""
332+
errors: list[str] = []
333+
monkeypatch.setattr(PLAN.os, "name", "nt")
334+
PLAN._validate_strings(r"C:\DeePMD\python.exe", "environment.python", errors)
335+
assert errors == []
336+
337+
328338
@pytest.mark.parametrize(
329339
("field", "value"),
330340
[

0 commit comments

Comments
 (0)