Merge branch 'patch-bio' into 'develop'

replace newlines in profiles with <br>

See merge request pleroma/pleroma!136
This commit is contained in:
lambda 2018-04-29 09:26:47 +00:00
commit b7584edcea
2 changed files with 18 additions and 1 deletions

View File

@ -347,7 +347,8 @@ defmodule Pleroma.Web.TwitterAPI.Controller 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,"<br>")
Map.put(params, "bio", bio_brs)
else
params
end

View File

@ -784,4 +784,20 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
assert status["id"] == activity.id
end
end
test "Convert newlines to <br> 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,<br>World! I<br> am a test."
end
end