From 52ee91efcedb1a004c27e27f252420c1f91f18dc Mon Sep 17 00:00:00 2001 From: Wim Vanderbauwhede Date: Tue, 24 Apr 2018 13:20:17 +0100 Subject: [PATCH 1/3] Patch to replace newlines with
tags in bio --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 6cf8682b8..0ee90496f 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -347,7 +347,8 @@ def empty_array(conn, _params) do def update_profile(%{assigns: %{user: user}} = conn, params) do params = if bio = params["description"] do - Map.put(params, "bio", bio) + bio_brs = Regex.replace(~r/\r\n/,bio,"
") + Map.put(params, "bio", bio_brs) else params end From 7517155544f85f0bd085c0ef0dd843fdac1fc4fd Mon Sep 17 00:00:00 2001 From: Wim Vanderbauwhede Date: Tue, 24 Apr 2018 13:28:55 +0100 Subject: [PATCH 2/3] Changed to support \r\n and \n --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 0ee90496f..e8fc9c291 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -347,7 +347,7 @@ def empty_array(conn, _params) do def update_profile(%{assigns: %{user: user}} = conn, params) do params = if bio = params["description"] do - bio_brs = Regex.replace(~r/\r\n/,bio,"
") + bio_brs = Regex.replace(~r/\r?\n/,bio,"
") Map.put(params, "bio", bio_brs) else params From 6908f29e0a170131d2f328d68d36f054b592a0a3 Mon Sep 17 00:00:00 2001 From: Wim Vanderbauwhede Date: Sat, 28 Apr 2018 12:01:43 +0100 Subject: [PATCH 3/3] Added a test (written by @andrewzah) for the MR --- .../twitter_api/twitter_api_controller_test.exs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 406dace1c..c239239d3 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -784,4 +784,20 @@ test "it returns the tags timeline", %{conn: conn} do assert status["id"] == activity.id end end + + test "Convert newlines to
in bio", %{conn: conn} do + user = insert(:user) + + conn = + conn + |> assign(:user, user) + |> post("/api/account/update_profile.json", %{ + "description" => "Hello,\r\nWorld! I\n am a test." + }) + + user = Repo.get!(User, user.id) + assert user.bio == "Hello,
World! I
am a test." + end + + end