Skip to content

Commit 20c290f

Browse files
Copilotbytemain
andauthored
Pass hash path as PowerShell argument
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 ffd2607 commit 20c290f

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

lib/util.lua

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,6 @@ 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-
274263
local function startsWith(value, prefix)
275264
return string.sub(value, 1, string.len(prefix)) == prefix
276265
end
@@ -484,7 +473,8 @@ local function verifyUvBuildArchive(path, sha256)
484473
local status
485474
if RUNTIME.osType == "windows" or OS_TYPE == "windows" then
486475
local command = "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command " ..
487-
shellQuote("(Get-FileHash -LiteralPath " .. powershellSingleQuotedLiteral(path) .. " -Algorithm SHA256).Hash")
476+
shellQuote("& { param([string]$p) (Get-FileHash -LiteralPath $p -Algorithm SHA256).Hash }") ..
477+
" " .. shellQuote(path)
488478
local handle = io.popen(command)
489479
if handle == nil then
490480
error("Unable to verify uv-build archive sha256 for " .. path .. ": powershell Get-FileHash command could not be started")

0 commit comments

Comments
 (0)