File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -260,6 +260,17 @@ local function shellQuote(value)
260260 return " '" .. string.gsub (value , " '" , " '\\ ''" ) .. " '"
261261end
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+
263274local function startsWith (value , prefix )
264275 return string.sub (value , 1 , string.len (prefix )) == prefix
265276end
@@ -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" )
You can’t perform that action at this time.
0 commit comments