logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: a990374e80ece3d28ae23f603bd5e301886e6a0c
parent: d7b40dd4ba5bf3890be8a8b69d5aff84f5ffc5d2
Author: lain <lain@soykaf.club>
Date:   Fri, 29 Nov 2019 10:10:30 +0000

Merge branch 'fix/extract_first_external_url' into 'develop'

Fix Pleroma.HTML.extract_first_external_url/2

Closes #1451

See merge request pleroma/pleroma!2024

Diffstat:

Mlib/pleroma/html.ex1+
Mtest/html_test.exs11+++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex @@ -91,6 +91,7 @@ defmodule Pleroma.HTML do Cachex.fetch!(:scrubber_cache, key, fn _key -> result = content + |> HtmlEntities.decode() |> 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 @@ -228,5 +228,16 @@ defmodule Pleroma.HTMLTest do assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140" end + + test "does not crash when there is an HTML entity in a link" do + user = insert(:user) + + {:ok, activity} = + CommonAPI.post(user, %{"status" => "\"http://cofe.com/?boomer=ok&foo=bar\""}) + + object = Object.normalize(activity) + + assert {:ok, nil} = HTML.extract_first_external_url(object, object.data["content"]) + end end end