1
0
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:
patrik
2012-02-11 17:50:48 +00:00
parent 48423a8a88
commit e8dad669ef
2 changed files with 8 additions and 3 deletions

View File

@@ -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

View File

@@ -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