diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-09-02 00:14:25 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-10-05 20:49:34 +0000 |
commit | b1be9415effadf81e557eddee3f60bdf0fa359af (patch) | |
tree | b307cd06e023c68977f39736fc8aaecf89a9bc5f /test | |
parent | f7ba393bb94f29bb79bc34ff3c708f929f61cc57 (diff) | |
download | pleroma-b1be9415effadf81e557eddee3f60bdf0fa359af.tar.gz |
Revert "Merge branch 'revert-a26d5e6b' into 'develop'"
This reverts commit d31bbb1cfe04ca6073a322bcf77239e7d4b79839, reversing
changes made to 340ab3cb9068d444b77213e07beb8c2c3ca128b9.
Diffstat (limited to 'test')
-rw-r--r-- | test/web/common_api/common_api_test.exs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 2a2c40833..cd5aca961 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -21,4 +21,36 @@ defmodule Pleroma.Web.CommonAPI.Test do assert karjalanpiirakka["name"] == ":karjalanpiirakka:" end + + describe "posting" do + test "it filters out obviously bad tags when accepting a post as HTML" do + user = insert(:user) + + post = "<h1>2hu</h1><script>alert('xss')</script>" + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => post, + "content_type" => "text/html" + }) + + content = activity.data["object"]["content"] + assert content == "<h1>2hu</h1>alert('xss')" + end + + test "it filters out obviously bad tags when accepting a post as Markdown" do + user = insert(:user) + + post = "<h1>2hu</h1><script>alert('xss')</script>" + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => post, + "content_type" => "text/markdown" + }) + + content = activity.data["object"]["content"] + assert content == "<h1>2hu</h1>alert('xss')" + end + end end |