From b79c126ee0977e44e21f275418862fede0e1f346 Mon Sep 17 00:00:00 2001 From: Dominique Feyer Date: Sun, 9 Sep 2018 23:31:47 +0200 Subject: [PATCH] Add missing URL encoding in create authorization redirect --- lib/pleroma/web/oauth/oauth_controller.ex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index 160cedd8e..8fe0dde6e 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -39,15 +39,18 @@ def create_authorization(conn, %{ }) else connector = if String.contains?(redirect_uri, "?"), do: "&", else: "?" - url = "#{redirect_uri}#{connector}code=#{auth.token}" + url = "#{redirect_uri}#{connector}" + url_params = %{:code => auth.token} - url = + url_params = if params["state"] do - url <> "&state=#{params["state"]}" + Map.put(url_params, :state, params["state"]) else - url + url_params end + url = "#{url}#{Plug.Conn.Query.encode url_params}" + redirect(conn, external: url) end end