Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated URL params parsing #419

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/url.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h2 id="url">URL</h2>

<blockquote>
<tt>
&lt;url&gt; ::= [&lt;scheme&gt;:][//&lt;authority&gt;][/&lt;path&gt;][;&lt;params&gt;][?&lt;query&gt;][#&lt;fragment&gt;]<br>
&lt;url&gt; ::= [&lt;scheme&gt;:][//&lt;authority&gt;][/&lt;path&gt;][?&lt;query&gt;][#&lt;fragment&gt;]<br>
&lt;authority&gt; ::= [&lt;userinfo&gt;@]&lt;host&gt;[:&lt;port&gt;]<br>
&lt;userinfo&gt; ::= &lt;user&gt;[:&lt;password&gt;]<br>
&lt;path&gt; ::= {&lt;segment&gt;/}&lt;segment&gt;<br>
Expand Down Expand Up @@ -225,7 +225,6 @@ <h2 id="url">URL</h2>
&nbsp;&nbsp;scheme = <i>string</i>,<br>
&nbsp;&nbsp;authority = <i>string</i>,<br>
&nbsp;&nbsp;path = <i>string</i>,<br>
&nbsp;&nbsp;params = <i>string</i>,<br>
&nbsp;&nbsp;query = <i>string</i>,<br>
&nbsp;&nbsp;fragment = <i>string</i>,<br>
&nbsp;&nbsp;userinfo = <i>string</i>,<br>
Expand Down Expand Up @@ -255,7 +254,6 @@ <h2 id="url">URL</h2>
-- scheme = "ftp",
-- authority = "root:[email protected]",
-- path = "/pub/virus.exe",
-- params = "type=i",
-- userinfo = "root:passwd",
-- host = "unsafe.org",
-- user = "root",
Expand Down
1 change: 0 additions & 1 deletion src/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
17 changes: 4 additions & 13 deletions src/url.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
-- <url> ::= <scheme>://<authority>/<path>;<params>?<query>#<fragment>
-- <url> ::= <scheme>://<authority>/<path>?<query>#<fragment>
-- <authority> ::= <userinfo>@<host>:<port>
-- <userinfo> ::= <user>[:<password>]
-- <path> :: = {<segment>/}<segment>
Expand All @@ -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 {/<path>} is considered part of <path>
-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 "",
Expand Down
79 changes: 26 additions & 53 deletions test/urltest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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{
Expand All @@ -167,8 +162,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
Expand All @@ -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",
}
Expand All @@ -196,8 +189,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = ""
}
Expand All @@ -210,8 +202,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "",
fragment = "fragment"
}
Expand All @@ -224,8 +215,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
fragment = "fragment"
}

Expand All @@ -237,8 +227,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "",
path = "/path;",
query = "query",
fragment = "fragment"
}
Expand All @@ -264,8 +253,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/",
params = "params",
path = "/;params",
query = "query",
fragment = "fragment"
}
Expand All @@ -287,8 +275,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
Expand Down Expand Up @@ -438,8 +425,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
Expand All @@ -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"
}
Expand All @@ -467,8 +452,7 @@ check_build_url {
port = "port",
user = "user",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
Expand All @@ -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"
}
Expand All @@ -491,8 +474,7 @@ check_build_url{
port = "port",
user = "user",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
Expand All @@ -503,8 +485,7 @@ check_build_url {
host = "host",
user = "user",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
Expand All @@ -514,8 +495,7 @@ check_build_url {
scheme = "scheme",
host = "host",
user = "user",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
Expand All @@ -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"
}
Expand All @@ -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"
}

Expand Down Expand Up @@ -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"
}

Expand All @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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"
}
Expand Down
Loading