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 @@ def empty_array(conn, _params) do
def update_profile(%{assigns: %{user: user}} = conn, params) do def update_profile(%{assigns: %{user: user}} = conn, params) do
params = params =
if bio = params["description"] do 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 else
params params
end end

View file

@ -784,4 +784,20 @@ test "it returns the tags timeline", %{conn: conn} do
assert status["id"] == activity.id assert status["id"] == activity.id
end end
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 end