Skip to content

Commit 964fae5

Browse files
authored
Add URI decoding for route segments and test unicode path handling (#6559)
1 parent 07fc5ac commit 964fae5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/phoenix/verified_routes.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ defmodule Phoenix.VerifiedRoutes do
329329
|> Enum.at(0)
330330
|> String.split("/")
331331
|> Enum.filter(fn segment -> segment != "" end)
332+
|> Enum.map(&URI.decode/1)
332333
end
333334

334335
defp expand_alias({:__aliases__, _, _} = alias, env),

test/phoenix/verified_routes_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ defmodule Phoenix.VerifiedRoutesTest do
5656
get "/posts/file/*file", PostController, :file
5757
get "/posts/skip", PostController, :skip
5858
get "/should-warn/*all", PostController, :all, warn_on_verify: true
59+
get "/ø", PostController, :unicode
5960

6061
scope "/", host: "users." do
6162
post "/host_users/:id/info", UserController, :create
@@ -434,6 +435,10 @@ defmodule Phoenix.VerifiedRoutesTest do
434435
assert ~p"/posts/5/?#{%{"id" => "foo bar"}}" == "/posts/5/?id=foo+bar"
435436
end
436437

438+
test "~p with unicode characters" do
439+
assert ~p"" == "/%C3%B8"
440+
end
441+
437442
describe "with static path" do
438443
@endpoint StaticPath
439444
@router Router

0 commit comments

Comments
 (0)