logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: 07ff2d62f4d6d0b449ef71423c1c71859406f9ea
parent: 651f269568cb7e54cd96d8a0d8ea3533f77e9a3a
Author: lain <lain@soykaf.club>
Date:   Mon, 29 Jun 2020 12:44:58 +0000

Merge branch 'rich-media-parser-exclude-attachment-links' into 'develop'

excluding attachment links from RichMedia

See merge request pleroma/pleroma!2702

Diffstat:

Mlib/pleroma/html.ex2+-
Mtest/html_test.exs14++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex @@ -109,7 +109,7 @@ defmodule Pleroma.HTML do result = content |> Floki.parse_fragment!() - |> Floki.filter_out("a.mention,a.hashtag,a[rel~=\"tag\"]") + |> Floki.filter_out("a.mention,a.hashtag,a.attachment,a[rel~=\"tag\"]") |> Floki.attribute("a", "href") |> Enum.at(0) diff --git a/test/html_test.exs b/test/html_test.exs @@ -237,5 +237,19 @@ defmodule Pleroma.HTMLTest do assert {:ok, nil} = HTML.extract_first_external_url(object, object.data["content"]) end + + test "skips attachment links" do + user = insert(:user) + + {:ok, activity} = + CommonAPI.post(user, %{ + status: + "<a href=\"https://pleroma.gov/media/d24caa3a498e21e0298377a9ca0149a4f4f8b767178aacf837542282e2d94fb1.png?name=image.png\" class=\"attachment\">image.png</a>" + }) + + object = Object.normalize(activity) + + assert {:ok, nil} = HTML.extract_first_external_url(object, object.data["content"]) + end end end