From f9d13558c8198bf2a25035dfb3c112aaa2be4cbf Mon Sep 17 00:00:00 2001 From: eal Date: Sun, 12 Aug 2018 22:24:10 +0300 Subject: CommonAPI: add emoji to user source data on update --- test/web/common_api/common_api_test.exs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index a5da271b3..2a2c40833 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -1,6 +1,7 @@ defmodule Pleroma.Web.CommonAPI.Test do use Pleroma.DataCase alias Pleroma.Web.CommonAPI + alias Pleroma.User import Pleroma.Factory @@ -10,4 +11,14 @@ defmodule Pleroma.Web.CommonAPI.Test do assert activity.data["object"]["tag"] == ["2hu"] end + + test "it adds emoji when updating profiles" do + user = insert(:user, %{name: ":karjalanpiirakka:"}) + + CommonAPI.update(user) + user = User.get_cached_by_ap_id(user.ap_id) + [karjalanpiirakka] = user.info["source_data"]["tag"] + + assert karjalanpiirakka["name"] == ":karjalanpiirakka:" + end end -- cgit v1.2.3 From e7871ed05e9ebc8e2fe2f1afe966285e767c682f Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 31 Aug 2018 03:34:56 +0000 Subject: tests: add tests for evil HTML filtering --- test/web/common_api/common_api_test.exs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') 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 = "

2hu

" + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => post, + "content_type" => "text/html" + }) + + content = activity.data["object"]["content"] + assert content == "

2hu

alert('xss')" + end + + test "it filters out obviously bad tags when accepting a post as Markdown" do + user = insert(:user) + + post = "

2hu

" + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => post, + "content_type" => "text/markdown" + }) + + content = activity.data["object"]["content"] + assert content == "

2hu

alert('xss')" + end + end end -- cgit v1.2.3 From 58539e13573681238fdd4d4e7334666389084be3 Mon Sep 17 00:00:00 2001 From: lambda Date: Fri, 31 Aug 2018 09:51:20 +0000 Subject: Revert "Merge branch 'feature/rich-text' into 'develop'" This reverts merge request !309 --- test/web/common_api/common_api_test.exs | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index cd5aca961..2a2c40833 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -21,36 +21,4 @@ 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 = "

2hu

" - - {:ok, activity} = - CommonAPI.post(user, %{ - "status" => post, - "content_type" => "text/html" - }) - - content = activity.data["object"]["content"] - assert content == "

2hu

alert('xss')" - end - - test "it filters out obviously bad tags when accepting a post as Markdown" do - user = insert(:user) - - post = "

2hu

" - - {:ok, activity} = - CommonAPI.post(user, %{ - "status" => post, - "content_type" => "text/markdown" - }) - - content = activity.data["object"]["content"] - assert content == "

2hu

alert('xss')" - end - end end -- cgit v1.2.3 From b1be9415effadf81e557eddee3f60bdf0fa359af Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 2 Sep 2018 00:14:25 +0000 Subject: Revert "Merge branch 'revert-a26d5e6b' into 'develop'" This reverts commit d31bbb1cfe04ca6073a322bcf77239e7d4b79839, reversing changes made to 340ab3cb9068d444b77213e07beb8c2c3ca128b9. --- test/web/common_api/common_api_test.exs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/web/common_api/common_api_test.exs') 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 = "

2hu

" + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => post, + "content_type" => "text/html" + }) + + content = activity.data["object"]["content"] + assert content == "

2hu

alert('xss')" + end + + test "it filters out obviously bad tags when accepting a post as Markdown" do + user = insert(:user) + + post = "

2hu

" + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => post, + "content_type" => "text/markdown" + }) + + content = activity.data["object"]["content"] + assert content == "

2hu

alert('xss')" + end + end end -- cgit v1.2.3 From 497814cbbb4baea91b2882fbddd5cd8d5ad6e170 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 5 Oct 2018 21:11:22 +0000 Subject: test: update test for new html scrub policy --- test/web/common_api/common_api_test.exs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/web/common_api/common_api_test.exs') diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index cd5aca961..cd36e409c 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -26,7 +26,7 @@ defmodule Pleroma.Web.CommonAPI.Test do test "it filters out obviously bad tags when accepting a post as HTML" do user = insert(:user) - post = "

2hu

" + post = "

2hu

" {:ok, activity} = CommonAPI.post(user, %{ @@ -35,13 +35,13 @@ defmodule Pleroma.Web.CommonAPI.Test do }) content = activity.data["object"]["content"] - assert content == "

2hu

alert('xss')" + assert content == "

2hu

alert('xss')" end test "it filters out obviously bad tags when accepting a post as Markdown" do user = insert(:user) - post = "

2hu

" + post = "

2hu

" {:ok, activity} = CommonAPI.post(user, %{ @@ -50,7 +50,7 @@ defmodule Pleroma.Web.CommonAPI.Test do }) content = activity.data["object"]["content"] - assert content == "

2hu

alert('xss')" + assert content == "

2hu

alert('xss')" end end end -- cgit v1.2.3