From 7b41e103e1146ed2912cd2c336079947fef71e9a Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 18 Jun 2017 13:17:35 +0200 Subject: [PATCH] Remove html from user bios on display. This is mainly to fix problems of bios coming from mastodong. --- .../web/twitter_api/representers/user_representer.ex | 2 +- test/web/twitter_api/representers/user_representer_test.exs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/twitter_api/representers/user_representer.ex b/lib/pleroma/web/twitter_api/representers/user_representer.ex index 8a7bb6f0d..a6595f349 100644 --- a/lib/pleroma/web/twitter_api/representers/user_representer.ex +++ b/lib/pleroma/web/twitter_api/representers/user_representer.ex @@ -18,7 +18,7 @@ def to_map(user, opts) do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, - "description" => user.bio, + "description" => HtmlSanitizeEx.strip_tags(user.bio), "following" => following, "created_at" => created_at, # Fake fields diff --git a/test/web/twitter_api/representers/user_representer_test.exs b/test/web/twitter_api/representers/user_representer_test.exs index d63f738a9..f62ce1da3 100644 --- a/test/web/twitter_api/representers/user_representer_test.exs +++ b/test/web/twitter_api/representers/user_representer_test.exs @@ -8,7 +8,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.UserRepresenterTest do import Pleroma.Factory setup do - user = insert(:user) + user = insert(:user, bio: "Here's some html") [user: user] end @@ -39,7 +39,7 @@ test "A user" do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, - "description" => user.bio, + "description" => HtmlSanitizeEx.strip_tags(user.bio), "created_at" => created_at, # Fake fields "favourites_count" => 0, @@ -66,7 +66,7 @@ test "A user for a given other follower", %{user: user} do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, - "description" => user.bio, + "description" => HtmlSanitizeEx.strip_tags(user.bio), "created_at" => created_at, # Fake fields "favourites_count" => 0,