@@ -246,6 +246,17 @@ local function shellQuote(value)
246246 return " '" .. string.gsub (value , " '" , " '\\ ''" ) .. " '"
247247end
248248
249+ local function powershellQuote (value )
250+ if string.find (value , " [\r\n %z]" ) then
251+ error (" Path contains unsupported control character: " .. value )
252+ end
253+ if string.find (value , " %.%.%/" ) or string.find (value , " %.%.\\ " ) then
254+ error (" Path contains unsupported traversal segment: " .. value )
255+ end
256+
257+ return " '" .. string.gsub (value , " '" , " ''" ) .. " '"
258+ end
259+
249260local function startsWith (value , prefix )
250261 return string.sub (value , 1 , string.len (prefix )) == prefix
251262end
@@ -458,15 +469,17 @@ local function verifyUvBuildArchive(path, sha256)
458469
459470 local status
460471 if RUNTIME .osType == " windows" or OS_TYPE == " windows" then
461- local handle = io.popen (" certutil -hashfile " .. shellQuote (path ) .. " SHA256" )
472+ local command = " powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command " ..
473+ shellQuote (" (Get-FileHash -LiteralPath " .. powershellQuote (path ) .. " -Algorithm SHA256).Hash" )
474+ local handle = io.popen (command )
462475 if handle == nil then
463- error (" Unable to verify uv-build archive sha256 for " .. path .. " : certutil command could not be started" )
476+ error (" Unable to verify uv-build archive sha256 for " .. path .. " : powershell Get-FileHash command could not be started" )
464477 end
465478
466479 local output = handle :read (" *a" )
467480 handle :close ()
468481 if output == nil then
469- error (" Unable to verify uv-build archive sha256 for " .. path .. " : failed to read certutil output" )
482+ error (" Unable to verify uv-build archive sha256 for " .. path .. " : failed to read Get-FileHash output" )
470483 end
471484 local actualSha256
472485 for line in string.gmatch (output , " [^\r\n ]+" ) do
0 commit comments