fix: strip HTML tags from derived excerpt
gsub(/<[^>]+>/, '') before stripping markdown markup, so auto-generated excerpts don't leak raw HTML from post bodies.
This commit is contained in:
@@ -30,6 +30,12 @@ class PostTest < Minitest::Test
|
||||
assert_equal "The body paragraph.", post.excerpt
|
||||
end
|
||||
|
||||
def test_derived_excerpt_strips_html_tags
|
||||
body = "<strong>Bold</strong> and <em>italic</em>."
|
||||
post = Volumen::Post.new(metadata: { "slug" => "x" }, body: body)
|
||||
assert_equal "Bold and italic.", post.excerpt
|
||||
end
|
||||
|
||||
def test_summary_shape
|
||||
post = Volumen::Post.new(metadata: { "slug" => "x", "title" => "X" }, body: "Body")
|
||||
summary = post.summary
|
||||
|
||||
Reference in New Issue
Block a user