1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-24 16:39:03 +00:00

Add the missing dirname function to http-favicon.nse. I missed this when

I copied parse_url_relative from favicon-survey.nse. Ron Meldau reported
that this error is raised:
  http-favicon.nse:141: variable 'dirname' is not declared
It happens when a web page specifies a relative icon URL in a link
element. (dirname is used to absolutize the URL.)

Also, I changed to code to be sure to pass a plain string and number for
the host and port to parse_url_relative. Otherwise parse_url_relative
may return the tables that it receives and complicate the matching code
to decide if a URL should be followed.
This commit is contained in:
david
2010-01-22 18:45:04 +00:00
parent c6508cceb6
commit a066cd7bdc
2 changed files with 14 additions and 1 deletions

View File

@@ -81,8 +81,9 @@ action = function(host, port)
icon = parseIcon( index.body )
-- if we find a pattern
if icon then
local hostname = host.targetname or (host.name ~= "" and host.name) or host.ip
stdnse.print_debug(1, "Got icon URL %s.", icon)
local icon_host, icon_port, icon_path = parse_url_relative(icon, host, port, root)
local icon_host, icon_port, icon_path = parse_url_relative(icon, hostname, port.number, root)
if (icon_host == host.ip or
icon_host == host.targetname or
icon_host == (host.name ~= '' and host.name)) and
@@ -122,6 +123,12 @@ action = function(host, port)
return result
end
local function dirname(path)
local dir
dir = string.match(path, "^(.*)/")
return dir or ""
end
-- Return a URL's host, port, and path, filling in the results with the given
-- host, port, and path if the URL is relative. Return nil if the scheme is not
-- "http" or "https".