Skip to content

Commit ffd2607

Browse files
Copilotbytemain
andauthored
Pass Windows hash path as PowerShell literal
Agent-Logs-Url: https://github.com/version-fox/vfox-python/sessions/5852e539-b06d-4c0c-b5d1-b981726a91d9 Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
1 parent 88ffa31 commit ffd2607

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/util.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,17 @@ local function shellQuote(value)
260260
return "'" .. string.gsub(value, "'", "'\\''") .. "'"
261261
end
262262

263+
local function powershellSingleQuotedLiteral(value)
264+
if string.find(value, "[\r\n%z]") then
265+
error("Path contains unsupported control character: " .. value)
266+
end
267+
if containsTraversalSegment(value) then
268+
error("Path contains unsupported traversal segment: " .. value)
269+
end
270+
271+
return "'" .. string.gsub(value, "'", "''") .. "'"
272+
end
273+
263274
local function startsWith(value, prefix)
264275
return string.sub(value, 1, string.len(prefix)) == prefix
265276
end
@@ -472,9 +483,8 @@ local function verifyUvBuildArchive(path, sha256)
472483

473484
local status
474485
if RUNTIME.osType == "windows" or OS_TYPE == "windows" then
475-
os.setenv("VFOX_PYTHON_HASH_PATH", path)
476486
local command = "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command " ..
477-
shellQuote("(Get-FileHash -LiteralPath $env:VFOX_PYTHON_HASH_PATH -Algorithm SHA256).Hash")
487+
shellQuote("(Get-FileHash -LiteralPath " .. powershellSingleQuotedLiteral(path) .. " -Algorithm SHA256).Hash")
478488
local handle = io.popen(command)
479489
if handle == nil then
480490
error("Unable to verify uv-build archive sha256 for " .. path .. ": powershell Get-FileHash command could not be started")

0 commit comments

Comments
 (0)