1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeTextTest do
8 alias Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeText
10 test "it lets normal text go through" do
11 text = "hey how are you"
12 assert {:ok, text} == SafeText.cast(text)
15 test "it removes html tags from text" do
16 text = "hey look xss <script>alert('foo')</script>"
17 assert {:ok, "hey look xss alert('foo')"} == SafeText.cast(text)
20 test "errors for non-text" do
21 assert :error == SafeText.cast(1)