When doing markdown to HTML, sanitize HTML

Closes #101
Closes #102
This commit is contained in:
Claudio Ortolina
2026-03-07 19:05:37 +00:00
parent 84ffcc720b
commit 52815bde2f
8 changed files with 44 additions and 0 deletions
@@ -156,6 +156,8 @@ defmodule MusicLibraryWeb.Components.Notes do
end
end
# sobelow_skip ["XSS.Raw"]
# Markdown.to_html/1 sanitizes HTML via HtmlSanitizeEx
defp render_content(content) do
content
|> Markdown.to_html()
@@ -346,6 +346,8 @@ defmodule MusicLibraryWeb.SearchComponents do
"""
end
# sobelow_skip ["XSS.Raw"]
# Markdown.to_html/1 sanitizes HTML via HtmlSanitizeEx
defp render_description(description) do
description
|> String.slice(0, 100)
@@ -466,6 +466,8 @@ defmodule MusicLibraryWeb.RecordSetLive.Index do
"""
end
# sobelow_skip ["XSS.Raw"]
# Markdown.to_html/1 sanitizes HTML via HtmlSanitizeEx
defp render_description(description) do
description
|> Markdown.to_html()
@@ -302,6 +302,8 @@ defmodule MusicLibraryWeb.RecordSetLive.Show do
defp page_title(:edit, record_set), do: gettext("Edit") <> " · " <> record_set.name
defp page_title(:add_record, record_set), do: gettext("Add Record") <> " · " <> record_set.name
# sobelow_skip ["XSS.Raw"]
# Markdown.to_html/1 sanitizes HTML via HtmlSanitizeEx
defp render_description(description) do
description
|> Markdown.to_html()
+1
View File
@@ -22,6 +22,7 @@ defmodule MusicLibraryWeb.Markdown do
markdown_text
|> process_double_bracket_links()
|> Earmark.as_html!(%Earmark.Options{gfm: true})
|> HtmlSanitizeEx.markdown_html()
{result, %{}}
end