logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: 5c6c4ce634d6fe17f62b71871ecb28edc34a40dd
parent: 90e47d43578803cf74f760db7777cbaba50bb8d9
Author: lain <lain@soykaf.club>
Date:   Wed, 19 Jun 2019 08:48:41 +0000

Merge branch 'fix/rich-media-hashtags-again' into 'develop'

Rich Media: Skip Microformats hashtags

See merge request pleroma/pleroma!1304

Diffstat:

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

diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex @@ -89,7 +89,7 @@ defmodule Pleroma.HTML do Cachex.fetch!(:scrubber_cache, key, fn _key -> result = content - |> Floki.filter_out("a.mention,a.hashtag") + |> Floki.filter_out("a.mention,a.hashtag,a[rel~=\"tag\"]") |> Floki.attribute("a", "href") |> Enum.at(0) diff --git a/test/html_test.exs b/test/html_test.exs @@ -212,5 +212,21 @@ defmodule Pleroma.HTMLTest do assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140" end + + test "skips microformats hashtags" do + user = insert(:user) + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => + "<a href=\"https://pleroma.gov/tags/cofe\" rel=\"tag\">#cofe</a> https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140", + "content_type" => "text/html" + }) + + object = Object.normalize(activity) + {:ok, url} = HTML.extract_first_external_url(object, object.data["content"]) + + assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140" + end end end