logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: b748efe66a099b66300f2beda42f5639911bab4a
parent 340c8812963a71f5f04b12a4c540bad3871f87fd
Author: tusooa <tusooa@kazv.moe>
Date:   Sat, 29 Jul 2023 12:55:43 -0400

Fix mentioning punycode domains when using Markdown

Diffstat:

Achangelog.d/punycode-mention.fix1+
Mlib/pleroma/formatter.ex2+-
Mtest/pleroma/web/common_api_test.exs12++++++++++++
3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/changelog.d/punycode-mention.fix b/changelog.d/punycode-mention.fix @@ -0,0 +1 @@ +Fix mentioning punycode domains when using Markdown diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex @@ -124,7 +124,7 @@ defmodule Pleroma.Formatter do end def markdown_to_html(text) do - Earmark.as_html!(text, %Earmark.Options{compact_output: true}) + Earmark.as_html!(text, %Earmark.Options{compact_output: true, smartypants: false}) end def html_escape({text, mentions, hashtags}, type) do diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs @@ -843,6 +843,18 @@ defmodule Pleroma.Web.CommonAPITest do {:ok, _} = CommonAPI.post(user, %{status: "nice", quote_id: public.id}) {:ok, _} = CommonAPI.post(another_user, %{status: "nice", quote_id: public.id}) end + + test "it properly mentions punycode domain" do + user = insert(:user) + + _mentioned_user = + insert(:user, ap_id: "https://xn--i2raa.com/users/yyy", nickname: "yyy@xn--i2raa.com") + + {:ok, activity} = + CommonAPI.post(user, %{status: "hey @yyy@xn--i2raa.com", content_type: "text/markdown"}) + + assert "https://xn--i2raa.com/users/yyy" in Object.normalize(activity).data["to"] + end end describe "reactions" do