mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Handle redirect URLs without a host, e.g. https:///path
This commit is contained in:
@@ -445,8 +445,10 @@ URL = {
|
|||||||
self.file = url.absolute("", self.file)
|
self.file = url.absolute("", self.file)
|
||||||
self.path = url.absolute("", self.path)
|
self.path = url.absolute("", self.path)
|
||||||
self.dir = self.path:match("^(.+%/)") or "/"
|
self.dir = self.path:match("^(.+%/)") or "/"
|
||||||
-- TODO: Use public suffix list to extract domain
|
if self.host then
|
||||||
self.domain= self.host:match("^[^%.]-%.(.*)")
|
-- TODO: Use public suffix list to extract domain
|
||||||
|
self.domain= self.host:match("^[^%.]-%.(.*)")
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -222,8 +222,10 @@ function parse(url, default)
|
|||||||
authority = string.gsub(authority, ":(%d+)$",
|
authority = string.gsub(authority, ":(%d+)$",
|
||||||
function(p) parsed.port = tonumber(p); return "" end)
|
function(p) parsed.port = tonumber(p); return "" end)
|
||||||
if authority ~= "" then parsed.host = authority end
|
if authority ~= "" then parsed.host = authority end
|
||||||
-- TODO: Allow other Unicode encodings
|
if parsed.host then
|
||||||
parsed.ascii_host = idna.toASCII(unicode.decode(parsed.host, unicode.utf8_dec))
|
-- TODO: Allow other Unicode encodings
|
||||||
|
parsed.ascii_host = idna.toASCII(unicode.decode(parsed.host, unicode.utf8_dec))
|
||||||
|
end
|
||||||
local userinfo = parsed.userinfo
|
local userinfo = parsed.userinfo
|
||||||
if not userinfo then return parsed end
|
if not userinfo then return parsed end
|
||||||
userinfo = string.gsub(userinfo, ":([^:]*)$",
|
userinfo = string.gsub(userinfo, ":([^:]*)$",
|
||||||
|
|||||||
Reference in New Issue
Block a user