mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 20:29:03 +00:00
Fixed bug in redirection code reported by David. The redirect_ok function
would fail validating a location if the port passed to http.get or http.head was a number and not a table. [Patrik]
This commit is contained in:
@@ -1286,6 +1286,10 @@ function redirect_ok(host, port)
|
||||
}
|
||||
|
||||
local counter = MAX_REDIRECT_COUNT
|
||||
-- convert a numeric port to a table
|
||||
if ( "number" == type(port) ) then
|
||||
port = { number = port }
|
||||
end
|
||||
return function(url)
|
||||
if ( counter == 0 ) then return false end
|
||||
counter = counter - 1
|
||||
|
||||
@@ -636,11 +636,12 @@ Crawler = {
|
||||
-- were we redirected?
|
||||
if ( response.location ) then
|
||||
-- was the link absolute?
|
||||
if ( response.location:match("^http") ) then
|
||||
url = URL:new(response.location)
|
||||
local link = response.location[#response.location]
|
||||
if ( link:match("^http") ) then
|
||||
url = URL:new(link)
|
||||
-- guess not
|
||||
else
|
||||
url.path = response.location
|
||||
url.path = link
|
||||
end
|
||||
end
|
||||
-- if we have a response, proceed scraping it
|
||||
|
||||
Reference in New Issue
Block a user