Skip to content

Commit 3fbcf6b

Browse files
Copilotbytemain
andauthored
Clarify Windows hash command constants
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 20c290f commit 3fbcf6b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/util.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ local version_vault_url = "https://vault.vfox.dev/python/pyenv"
1515
local uv_build_vault_url = "https://vault.vfox.dev/python/uv-build"
1616
local UV_BUILD_GITHUB_RELEASE_PATTERN = "/releases/download/([^/]+)/([^/]+)$"
1717
local SHA256_HEX_LENGTH = 64
18+
local URL_ENCODED_DOT = "%2e"
1819

1920
-- request headers
2021
local REQUEST_HEADERS = {
@@ -231,7 +232,7 @@ end
231232
local function containsTraversalSegment(value)
232233
local normalizedValue = string.gsub(value, "\\", "/")
233234
local lowerValue = string.lower(normalizedValue)
234-
if string.find(lowerValue, "%2e", 1, true) then
235+
if string.find(lowerValue, URL_ENCODED_DOT, 1, true) then
235236
return true
236237
end
237238
for segment in string.gmatch(normalizedValue, "[^/]+") do
@@ -472,9 +473,9 @@ local function verifyUvBuildArchive(path, sha256)
472473

473474
local status
474475
if RUNTIME.osType == "windows" or OS_TYPE == "windows" then
476+
local getFileHashScript = "& { param([string]$p) (Get-FileHash -LiteralPath $p -Algorithm SHA256).Hash }"
475477
local command = "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command " ..
476-
shellQuote("& { param([string]$p) (Get-FileHash -LiteralPath $p -Algorithm SHA256).Hash }") ..
477-
" " .. shellQuote(path)
478+
shellQuote(getFileHashScript) .. " " .. shellQuote(path)
478479
local handle = io.popen(command)
479480
if handle == nil then
480481
error("Unable to verify uv-build archive sha256 for " .. path .. ": powershell Get-FileHash command could not be started")

0 commit comments

Comments
 (0)