Skip to content

Commit e205e68

Browse files
committed
Remove TODOs after Elixir v1.14+
1 parent d6d3344 commit e205e68

6 files changed

Lines changed: 12 additions & 42 deletions

File tree

lib/plug/conn/query.ex

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,15 @@ defmodule Plug.Conn.Query do
143143
end
144144

145145
defp decode_www_form(value, invalid_exception, validate_utf8) do
146-
# TODO: Remove rescue as this can't fail from Elixir v1.13
147-
try do
148-
URI.decode_www_form(value)
149-
rescue
150-
ArgumentError ->
151-
raise invalid_exception, "invalid urlencoded params, got #{value}"
152-
else
153-
binary ->
154-
case validate_utf8 do
155-
true -> Plug.Conn.Utils.validate_utf8!(binary, invalid_exception, "urlencoded params")
156-
false -> :ok
157-
module -> Plug.Conn.Utils.validate_utf8!(binary, module, "urlencoded params")
158-
end
159-
160-
binary
146+
binary = URI.decode_www_form(value)
147+
148+
case validate_utf8 do
149+
true -> Plug.Conn.Utils.validate_utf8!(binary, invalid_exception, "urlencoded params")
150+
false -> :ok
151+
module -> Plug.Conn.Utils.validate_utf8!(binary, module, "urlencoded params")
161152
end
153+
154+
binary
162155
end
163156

164157
@doc """

lib/plug/parsers/multipart.ex

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ defmodule Plug.Parsers.MULTIPART do
146146

147147
## Multipart
148148

149-
defp parse_multipart(conn, {m2p, {module, fun, args}, header_opts, opts}) do
150-
# TODO: Remove me once the deprecation is removed
151-
limit = apply(module, fun, args)
152-
parse_multipart(conn, {m2p, limit, header_opts, opts})
153-
end
154-
155149
defp parse_multipart(conn, {m2p, limit, headers_opts, opts}) do
156150
read_result = Plug.Conn.read_part_headers(conn, headers_opts)
157151
{:ok, limit, acc, conn} = parse_multipart(read_result, limit, opts, headers_opts, [])

lib/plug/router/utils.ex

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@ defmodule Plug.Router.Utils do
1313
Decodes path information for dispatching.
1414
"""
1515
def decode_path_info!(conn) do
16-
# TODO: Remove rescue as this can't fail from Elixir v1.13
17-
try do
18-
Enum.map(conn.path_info, &URI.decode/1)
19-
rescue
20-
e in ArgumentError ->
21-
reason = %Plug.Router.MalformedURIError{message: e.message}
22-
Plug.Conn.WrapperError.reraise(conn, :error, reason, __STACKTRACE__)
23-
end
16+
Enum.map(conn.path_info, &URI.decode/1)
2417
end
2518

2619
@doc """

lib/plug/static.ex

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ defmodule Plug.Static do
187187
segments = subset(at, conn.path_info)
188188

189189
if allowed?(only_rules, segments) do
190-
segments = Enum.map(segments, &uri_decode/1)
190+
segments = Enum.map(segments, &URI.decode/1)
191191

192192
if invalid_path?(segments) do
193193
raise InvalidPathError, "invalid path for static asset: #{conn.request_path}"
@@ -206,16 +206,6 @@ defmodule Plug.Static do
206206
conn
207207
end
208208

209-
defp uri_decode(path) do
210-
# TODO: Remove rescue as this can't fail from Elixir v1.13
211-
try do
212-
URI.decode(path)
213-
rescue
214-
ArgumentError ->
215-
raise InvalidPathError
216-
end
217-
end
218-
219209
defp allowed?(_only_rules, []), do: false
220210
defp allowed?({[], []}, _list), do: true
221211

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule Plug.MixProject do
1010
[
1111
app: :plug,
1212
version: @version,
13-
elixir: "~> 1.10",
13+
elixir: "~> 1.14",
1414
deps: deps(),
1515
package: package(),
1616
description: @description,

src/plug_multipart.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ form_data(Headers) ->
365365
false -> <<"text/plain">>;
366366
{_, T} -> T
367367
end,
368-
%% @todo Turns out this is unnecessary per RFC7578 4.7.
368+
%% Turns out this is unnecessary per RFC7578 4.7.
369369
TransferEncoding = case lists:keyfind(
370370
<<"content-transfer-encoding">>, 1, Headers) of
371371
false -> <<"7bit">>;

0 commit comments

Comments
 (0)