mirror of
https://github.com/nmap/nmap.git
synced 2025-12-17 21:19:01 +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
|
local counter = MAX_REDIRECT_COUNT
|
||||||
|
-- convert a numeric port to a table
|
||||||
|
if ( "number" == type(port) ) then
|
||||||
|
port = { number = port }
|
||||||
|
end
|
||||||
return function(url)
|
return function(url)
|
||||||
if ( counter == 0 ) then return false end
|
if ( counter == 0 ) then return false end
|
||||||
counter = counter - 1
|
counter = counter - 1
|
||||||
|
|||||||
@@ -636,11 +636,12 @@ Crawler = {
|
|||||||
-- were we redirected?
|
-- were we redirected?
|
||||||
if ( response.location ) then
|
if ( response.location ) then
|
||||||
-- was the link absolute?
|
-- was the link absolute?
|
||||||
if ( response.location:match("^http") ) then
|
local link = response.location[#response.location]
|
||||||
url = URL:new(response.location)
|
if ( link:match("^http") ) then
|
||||||
|
url = URL:new(link)
|
||||||
-- guess not
|
-- guess not
|
||||||
else
|
else
|
||||||
url.path = response.location
|
url.path = link
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- if we have a response, proceed scraping it
|
-- if we have a response, proceed scraping it
|
||||||
|
|||||||
Reference in New Issue
Block a user