From ac5a479a73ff5821d7d60f9a7f8c0326468afd99 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 7 Feb 2013 03:06:30 +0000 Subject: [PATCH] Treat empty port in URL the same as absent. RFC 3986 says that these URLs are equivalent: http://example.com/ http://example.com:/ url.parse was returning port="" for the latter. Make it instead return port=nil like the former. --- nselib/url.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nselib/url.lua b/nselib/url.lua index 0d8882094..4ce27742e 100644 --- a/nselib/url.lua +++ b/nselib/url.lua @@ -184,7 +184,7 @@ function parse(url, default) authority = string.gsub(authority,"^([^@]*)@", function(u) parsed.userinfo = u; return "" end) authority = string.gsub(authority, ":([0-9]*)$", - function(p) parsed.port = p; return "" end) + function(p) if p ~= "" then parsed.port = p end; return "" end) if authority ~= "" then parsed.host = authority end local userinfo = parsed.userinfo if not userinfo then return parsed end