Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into update-validator
[akkoma] / test / web / activity_pub / object_validators / types / safe_text_test.exs
index 59ed0a1febbc675744d6f3045b12f78266f44304..9c08606f6419aed0d164108685ba21838f3482f3 100644 (file)
@@ -5,7 +5,7 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeTextTest do
   use Pleroma.DataCase
 
-  alias Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeText
+  alias Pleroma.EctoType.ActivityPub.ObjectValidators.SafeText
 
   test "it lets normal text go through" do
     text = "hey how are you"
@@ -17,6 +17,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeTextTest do
     assert {:ok, "hey look xss alert('foo')"} == SafeText.cast(text)
   end
 
+  test "it keeps basic html tags" do
+    text = "hey <a href='http://gensokyo.2hu'>look</a> xss <script>alert('foo')</script>"
+
+    assert {:ok, "hey <a href=\"http://gensokyo.2hu\">look</a> xss alert(&#39;foo&#39;)"} ==
+             SafeText.cast(text)
+  end
+
   test "errors for non-text" do
     assert :error == SafeText.cast(1)
   end