From 92a7b3ae2241b862e9bf45e0af3cf53ebdfb0afb Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 25 Mar 2018 15:05:16 +0200 Subject: [PATCH] Fix a segfault with StripDown and the `:quote` option Since the `StripDown` render extends from `Base`, every available callback should be defined to avoid segmentation faults since the C code assumes that it **doesn't** deal with a `Base` object. Fixes #639. --- CHANGELOG.md | 5 +++++ lib/redcarpet/render_strip.rb | 2 +- test/stripdown_render_test.rb | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 590fb291..eafa26d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +* Fix a segfault rendering quotes using `StripDown` and the `:quote` + option. + + Fixes #639. + * Fix `warning: instance variable @options not initialized` when running under verbose mode (`-w`, `$VERBOSE = true`). diff --git a/lib/redcarpet/render_strip.rb b/lib/redcarpet/render_strip.rb index 769d72a3..415af399 100644 --- a/lib/redcarpet/render_strip.rb +++ b/lib/redcarpet/render_strip.rb @@ -13,7 +13,7 @@ class StripDown < Base :autolink, :codespan, :double_emphasis, :emphasis, :underline, :raw_html, :triple_emphasis, :strikethrough, - :superscript, :highlight, + :superscript, :highlight, :quote, # footnotes :footnotes, :footnote_def, :footnote_ref, diff --git a/test/stripdown_render_test.rb b/test/stripdown_render_test.rb index eb7368dd..53313a0d 100644 --- a/test/stripdown_render_test.rb +++ b/test/stripdown_render_test.rb @@ -58,4 +58,12 @@ def test_highlight assert_equal expected, output end + + def test_with_quote_option_enabled + markdown = %(A common idiom is "Hello world") + expected = %(A common idiom is Hello world) + output = render(markdown, with: [:quote]) + + assert_equal expected, output + end end