1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-27 18:09:01 +00:00

url.parse should convert all schemes to lower case.

RFC 3986 section 3.1:
Although schemes are case-insensitive, the canonical form is lowercase
and documents that specify schemes must do so with lowercase letters.
An implementation should accept uppercase letters as equivalent to
lowercase in scheme names (e.g., allow "HTTP" as well as "http") for the
sake of robustness but should only produce lowercase scheme names for
consistency.
This commit is contained in:
david
2013-02-07 23:43:47 +00:00
parent 5273567981
commit 4fb61350d8

View File

@@ -159,9 +159,9 @@ function parse(url, default)
parsed.fragment = f
return ""
end)
-- get scheme
-- get scheme. Lower-case according to RFC 3986 section 3.1.
url = string.gsub(url, "^([%w][%w%+%-%.]*)%:",
function(s) parsed.scheme = s; return "" end)
function(s) parsed.scheme = string.lower(s); return "" end)
-- get authority
url = string.gsub(url, "^//([^/]*)", function(n)
parsed.authority = n