Skip to content

Commit

Permalink
fix(http): separate hostname and port before host checks
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino authored and jaromil committed Oct 23, 2024
1 parent f084af0 commit 14df205
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lua/zencode_http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ function is_valid_uri(uri)
error("invalid uri, missing scheme in '" .. uri .. "'", 2)
end
if parsed.authority ~= "" then
local host_error = _is_valid_host(parsed.authority)
local authority_pattern = "^([^:]+):?(%d*)$"
parsed.hostname, parsed.port = parsed.authority:match(authority_pattern)
if parsed.port ~= "" and not tonumber(parsed.port) then
error("invalid port in '" .. parsed.authority .. "'", 2)
end
local host_error = _is_valid_host(parsed.hostname)
if host_error then
error(host_error, 2)
end
Expand Down

0 comments on commit 14df205

Please sign in to comment.