Skip to content

Commit 0dc5a26

Browse files
mnriemCopilot
andcommitted
fix(scripts): harden feature.json persistence
- Use json_escape in printf fallback when jq is unavailable (common.sh) - Replace utf8NoBOM encoding with UTF8Encoding($false) for PowerShell 5.1 compatibility (common.ps1) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 458449a commit 0dc5a26

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

scripts/bash/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ _persist_feature_json() {
135135
if command -v jq >/dev/null 2>&1; then
136136
jq -cn --arg fd "$feature_dir_value" '{feature_directory:$fd}' > "$fj"
137137
else
138-
printf '{"feature_directory":"%s"}\n' "$feature_dir_value" > "$fj"
138+
printf '{"feature_directory":"%s"}\n' "$(json_escape "$feature_dir_value")" > "$fj"
139139
fi
140140
}
141141

scripts/powershell/common.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ function Save-FeatureJson {
155155

156156
# Write feature.json
157157
$json = @{ feature_directory = $FeatureDirectory } | ConvertTo-Json -Compress
158-
Set-Content -LiteralPath $fjPath -Value $json -Encoding utf8NoBOM
158+
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
159+
[System.IO.File]::WriteAllText($fjPath, $json, $utf8NoBom)
159160
}
160161

161162
function Get-FeaturePathsEnv {

0 commit comments

Comments
 (0)