From a1b5d3abd1e841fad9e91a627634a927cac41078 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 9 Nov 2023 14:10:21 +0300 Subject: [PATCH 1/3] chore(url)!: Remove params parsing, part of deprecated URL schema --- src/http.lua | 1 - src/url.lua | 17 ++++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/http.lua b/src/http.lua index fbd5ff6..340f45a 100644 --- a/src/http.lua +++ b/src/http.lua @@ -207,7 +207,6 @@ local function adjusturi(reqt) if not reqt.proxy and not _M.PROXY then u = { path = socket.try(reqt.path, "invalid path 'nil'"), - params = reqt.params, query = reqt.query, fragment = reqt.fragment } diff --git a/src/url.lua b/src/url.lua index aef1698..fbba853 100644 --- a/src/url.lua +++ b/src/url.lua @@ -125,7 +125,7 @@ end ----------------------------------------------------------------------------- -- Parses a url and returns a table with all its parts according to RFC 2396 -- The following grammar describes the names given to the URL parts --- ::= :///;?# +-- ::= :///?# -- ::= @: -- ::= [:] -- :: = {/} @@ -136,7 +136,7 @@ end -- table with the following fields, where RFC naming conventions have -- been preserved: -- scheme, authority, userinfo, user, password, host, port, --- path, params, query, fragment +-- path, query, fragment -- Obs: -- the leading '/' in {/} is considered part of ----------------------------------------------------------------------------- @@ -166,11 +166,6 @@ function _M.parse(url, default) parsed.query = q return "" end) - -- get params - url = string.gsub(url, "%;(.*)", function(p) - parsed.params = p - return "" - end) -- path is whatever was left if url ~= "" then parsed.path = url end local authority = parsed.authority @@ -203,7 +198,6 @@ function _M.build(parsed) --local ppath = _M.parse_path(parsed.path or "") --local url = _M.build_path(ppath) local url = parsed.path or "" - if parsed.params then url = url .. ";" .. parsed.params end if parsed.query then url = url .. "?" .. parsed.query end local authority = parsed.authority if parsed.host then @@ -258,11 +252,8 @@ function _M.absolute(base_url, relative_url) relative_parsed.authority = base_parsed.authority if not relative_parsed.path then relative_parsed.path = base_parsed.path - if not relative_parsed.params then - relative_parsed.params = base_parsed.params - if not relative_parsed.query then - relative_parsed.query = base_parsed.query - end + if not relative_parsed.query then + relative_parsed.query = base_parsed.query end else relative_parsed.path = absolute_path(base_parsed.path or "", From 784b0631e15ba252ca07495a532b2d0b0932b047 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 9 Nov 2023 14:37:52 +0300 Subject: [PATCH 2/3] test(url): Update URL parsing expectations for params removal --- test/urltest.lua | 79 ++++++++++++++++-------------------------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/test/urltest.lua b/test/urltest.lua index 9a3c470..b6c8556 100644 --- a/test/urltest.lua +++ b/test/urltest.lua @@ -99,8 +99,7 @@ check_parse_url{ userinfo = "user:pass$%?#wd", password = "pass$%?#wd", user = "user", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -113,8 +112,7 @@ check_parse_url{ userinfo = "user:pass?#wd", password = "pass?#wd", user = "user", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -127,8 +125,7 @@ check_parse_url{ userinfo = "user:pass-wd", password = "pass-wd", user = "user", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -141,8 +138,7 @@ check_parse_url{ userinfo = "user:pass#wd", password = "pass#wd", user = "user", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -155,8 +151,7 @@ check_parse_url{ userinfo = "user:pass#wd", password = "pass#wd", user = "user", - path = "/path", - params = "params", + path = "/path;params", query = "query", } check_parse_url{ @@ -167,8 +162,7 @@ check_parse_url{ port = "port", userinfo = "userinfo", user = "userinfo", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -182,8 +176,7 @@ check_parse_url{ userinfo = "user:password", user = "user", password = "password", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment", } @@ -196,8 +189,7 @@ check_parse_url{ port = "port", userinfo = "userinfo", user = "userinfo", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "" } @@ -210,8 +202,7 @@ check_parse_url{ port = "port", userinfo = "userinfo", user = "userinfo", - path = "/path", - params = "params", + path = "/path;params", query = "", fragment = "fragment" } @@ -224,8 +215,7 @@ check_parse_url{ port = "port", userinfo = "userinfo", user = "userinfo", - path = "/path", - params = "params", + path = "/path;params", fragment = "fragment" } @@ -237,8 +227,7 @@ check_parse_url{ port = "port", userinfo = "userinfo", user = "userinfo", - path = "/path", - params = "", + path = "/path;", query = "query", fragment = "fragment" } @@ -264,8 +253,7 @@ check_parse_url{ port = "port", userinfo = "userinfo", user = "userinfo", - path = "/", - params = "params", + path = "/;params", query = "query", fragment = "fragment" } @@ -287,8 +275,7 @@ check_parse_url{ port = "port", userinfo = "userinfo", user = "userinfo", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -438,8 +425,7 @@ check_parse_url{ port = "port", userinfo = "userinfo", user = "userinfo", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -453,8 +439,7 @@ check_parse_url{ userinfo = "user:password", user = "user", password = "password", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -467,8 +452,7 @@ check_build_url { port = "port", user = "user", password = "password", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -478,8 +462,7 @@ check_build_url{ host = "::FFFF:129.144.52.38", port = "port", user = "userinfo", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -491,8 +474,7 @@ check_build_url{ port = "port", user = "user", password = "password", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -503,8 +485,7 @@ check_build_url { host = "host", user = "user", password = "password", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -514,8 +495,7 @@ check_build_url { scheme = "scheme", host = "host", user = "user", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -524,8 +504,7 @@ check_build_url { url = "scheme://host/path;params?query#fragment", scheme = "scheme", host = "host", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -534,8 +513,7 @@ check_build_url { url = "scheme://host/path;params#fragment", scheme = "scheme", host = "host", - path = "/path", - params = "params", + path = "/path;params", fragment = "fragment" } @@ -573,9 +551,7 @@ check_build_url { user = "user", userinfo = "not used", password = "password", - path = "/path", - params = "params", - query = "query", + path = "/path;params", fragment = "fragment" } @@ -588,8 +564,7 @@ check_build_url { userinfo = "not used", authority = "not used", password = "password", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -601,8 +576,7 @@ check_build_url { port = "port", userinfo = "user:password", authority = "not used", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } @@ -611,8 +585,7 @@ check_build_url { url = "scheme://user:password@host:port/path;params?query#fragment", scheme = "scheme", authority = "user:password@host:port", - path = "/path", - params = "params", + path = "/path;params", query = "query", fragment = "fragment" } From b281e6f7176c48b4bdeefd13135a090e3d7ae5f3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 9 Nov 2023 14:38:43 +0300 Subject: [PATCH 3/3] docs: Remove params documentation --- docs/url.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/url.html b/docs/url.html index 6ff673d..0673ac2 100644 --- a/docs/url.html +++ b/docs/url.html @@ -60,7 +60,7 @@ An URL is defined by the following grammar:
-<url> ::= [<scheme>:][//<authority>][/<path>][;<params>][?<query>][#<fragment>]
+<url> ::= [<scheme>:][//<authority>][/<path>][?<query>][#<fragment>]
<authority> ::= [<userinfo>@]<host>[:<port>]
<userinfo> ::= <user>[:<password>]
<path> ::= {<segment>/}<segment>
@@ -225,7 +225,6 @@ parsed_url = {
  scheme = string,
  authority = string,
  path = string,
-  params = string,
  query = string,
  fragment = string,
  userinfo = string,
@@ -255,7 +254,6 @@ parsed_url = url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i") -- scheme = "ftp", -- authority = "root:passwd@unsafe.org", -- path = "/pub/virus.exe", --- params = "type=i", -- userinfo = "root:passwd", -- host = "unsafe.org", -- user = "root",