From dc348e8be828a779fc232e31f2d8944527ec1e45 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Thu, 2 Jul 2026 12:48:52 +0400 Subject: [PATCH] fix(deps): adapt hackney and mdex behavior --- lib/pleroma/formatter.ex | 27 ++++++++-- lib/pleroma/reverse_proxy/client/hackney.ex | 50 ++++++++++++++++--- ...ackney_follow_redirect_regression_test.exs | 38 ++++++++------ 3 files changed, 89 insertions(+), 26 deletions(-) diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index a0f477a16..13dbb9e0d 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -131,12 +131,16 @@ defmodule Pleroma.Formatter do breaks = Map.get(opts, :breaks, false) text = normalize_markdown_quirks(text) - text - |> MDEx.to_html!( + MDEx.new( + markdown: text, extension: [autolink: true, strikethrough: true], parse: [smart: false], render: [hardbreaks: breaks, unsafe: true] ) + |> MDEx.Document.run() + |> MDEx.Document.update_nodes(MDEx.HtmlBlock, &strip_dangerous_raw_html/1) + |> MDEx.Document.update_nodes(MDEx.HtmlInline, &strip_dangerous_raw_html/1) + |> MDEx.to_html!() |> compact_markdown_html(text) end @@ -155,20 +159,33 @@ defmodule Pleroma.Formatter do end defp unwrap_raw_html_paragraph(html, markdown) do - if raw_html_only?(markdown) do + if inline_raw_html_only?(markdown) do String.replace(html, ~r/\A

(.*)<\/p>\z/s, "\\1") else html end end - defp raw_html_only?(markdown) do + defp inline_raw_html_only?(markdown) do markdown = String.trim(markdown) - String.match?(markdown, ~r/\A(?: