Author Build Commit PR
flavorjones 22324 1f0c247 n/a
Repo Branch
rails/rails main
Message
Escape attachment captions in `Attachment#to_markdown` (#58553) `Attachment#to_markdown` returned the caption unescaped when the attachable did not implement `attachable_markdown_representation`. The caption is document-derived, so a caption of `[click](javascript:alert(1))` emerged from a stored rich text body as a working Markdown link with an unchecked URI scheme. `to_markdown` is unreleased, so no released version is affected. Escape the caption with `MarkdownConversion.escape_markdown_text`. The four framework attachables all implement the representation method and never reach this branch, so their output is unchanged. Escaping the fallback does not cover an application's own implementation, which receives the same untrusted caption, so document the contract on `attachable_markdown_representation`. Its RDoc example also referenced `MarkdownConversion` unqualified, which raises `NameError` in a top-level model; qualify it.

/api

Reference documentation

/guides

In-depth tutorials