summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2023-07-29 12:55:43 -0400
committertusooa <tusooa@kazv.moe>2023-07-29 12:55:43 -0400
commita8d81f65a68d0a1e3da49fc5b44ecc7cd0cf4e9d (patch)
tree4cf9962ed681a2eca65643c2b9262b9b1bd8306f
parentb08cbe76f18c1e745511adf26ebdc3b675dd45ba (diff)
Fix mentioning punycode domains when using Markdowntusooa/2810-punycode-mention
-rw-r--r--changelog.d/punycode-mention.fix1
-rw-r--r--lib/pleroma/formatter.ex2
-rw-r--r--test/pleroma/web/common_api_test.exs12
3 files changed, 14 insertions, 1 deletions
diff --git a/changelog.d/punycode-mention.fix b/changelog.d/punycode-mention.fix
new file mode 100644
index 000000000..f013c2dac
--- /dev/null
+++ 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
index a46c3e381..11d5af2fb 100644
--- 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
index 968e11a14..dc3385f8b 100644
--- a/test/pleroma/web/common_api_test.exs
+++ b/test/pleroma/web/common_api_test.exs
@@ -778,6 +778,18 @@ defmodule Pleroma.Web.CommonAPITest do
scheduled_at: expires_at
)
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