aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-06-11 14:33:13 -0500
committerMark Felder <feld@feld.me>2021-06-11 14:35:05 -0500
commitbaf7fd2142a28ff2219c6be8906861490a9f0753 (patch)
tree673143ce191f70fddb6067ef50bb75e60bfe7a52 /test
parent65137044c1d68eade974e5b5ac5caea4352e6a44 (diff)
downloadpleroma-baf7fd2142a28ff2219c6be8906861490a9f0753.tar.gz
Introduce a scrubber that filters only everything except breaks
Add more tests for scrub_html_and_truncate/2
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/metadata/utils_test.exs16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/pleroma/web/metadata/utils_test.exs b/test/pleroma/web/metadata/utils_test.exs
index 8cdfb8ecc..b5d3e3566 100644
--- a/test/pleroma/web/metadata/utils_test.exs
+++ b/test/pleroma/web/metadata/utils_test.exs
@@ -30,5 +30,21 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
test "it truncates to specified chars (binaries)" do
assert Utils.scrub_html_and_truncate("Pleroma's really cool!", 10) == "Pleroma..."
end
+
+ # push notifications and link previews should be able to display newlines
+ test "it replaces <br> with compatible HTML entity (binaries)" do
+ assert Utils.scrub_html_and_truncate("First line<br>Second line") ==
+ "First line&#10;&#13;Second line"
+ end
+
+ test "it strips emojis (binaries)" do
+ assert Utils.scrub_html_and_truncate(
+ "Open the door get on the floor everybody walk the dinosaur :dinosaur:"
+ ) == "Open the door get on the floor everybody walk the dinosaur"
+ end
+
+ test "it strips HTML tags and other entities (binaries)" do
+ assert Utils.scrub_html_and_truncate("<title>my title</title> <p>and a paragraph&#33;</p>") == "my title and a paragraph!"
+ end
end
end