Add missing URL encoding in create authorization redirect
authorDominique Feyer <dfeyer@ttree.ch>
Sun, 9 Sep 2018 21:31:47 +0000 (23:31 +0200)
committerDominique Feyer <dfeyer@ttree.ch>
Sun, 9 Sep 2018 21:31:47 +0000 (23:31 +0200)
lib/pleroma/web/oauth/oauth_controller.ex

index 160cedd8ee304f3ab103e9097a630ea9fcbfa2f3..8fe0dde6e602d804d86427637aadb822edbb4f60 100644 (file)
@@ -39,15 +39,18 @@ defmodule Pleroma.Web.OAuth.OAuthController do
         })
       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