mirror of
https://git.openapi.site/https://github.com/desirecore/market.git
synced 2026-12-05 11:59:24 +08:00
fix(nodejs-runtime): 探测脚本输出的路径做 JSON 转义(1.0.5)/ escape paths in probe JSON (#244)
probe-node.sh 和 dev-environment-setup 的 probe.sh 直接把路径写进 JSON。路径带双引号或反斜杠时(比如 Windows 上的 DESIRECORE_ROOT)输出不合法,jq 和 Agent 都解析不了,违反 probe-snapshot.md 的「JSON 必合法」约定。 - 两个脚本加 json_escape,写法与 probe-python.sh 相同 - probe-node.sh 转义 system_node、system_npm、volta_path、nvm_path、fnm_path、registry、proxy;probe.sh 转义 tools.*.path - probe.ps1 用 ConvertTo-Json,不受影响 - 版本 nodejs-runtime 1.0.4 → 1.0.5、dev-environment-setup 2.0.6 → 2.0.7,sidecar 同步;技能正文没变,source_hash 不变 Escape paths written into the JSON output of probe-node.sh and probe.sh, so double quotes and backslashes no longer produce invalid JSON. 验证:含引号和反斜杠的路径修复前报 JSON 解析错误,修复后合法且值能还原、能执行;普通布局输出不变;i18n、catalog 校验 0 error,translate --check 通过。控制字符不处理。私有敏感词扫描未执行,经用户确认后合并。
This commit is contained in:
6 files changed
+19
-11
No files matched your search
@@ -5,6 +5,10 @@
|
||||
set +e
|
||||
|
||||
# ── 工具检测 ─────────────────────────────
|
||||
json_escape() {
|
||||
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
|
||||
}
|
||||
|
||||
detect_tool() {
|
||||
local name="$1"
|
||||
local version_flag="${2:---version}"
|
||||
@@ -16,7 +20,7 @@ detect_tool() {
|
||||
fi
|
||||
local version
|
||||
version=$("$name" $version_flag 2>&1 | head -n1 | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1)
|
||||
printf '{"available":true,"path":"%s","version":"%s"}' "$path" "${version:-}"
|
||||
printf '{"available":true,"path":"%s","version":"%s"}' "$(json_escape "$path")" "${version:-}"
|
||||
}
|
||||
|
||||
# ── 平台 ────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user