Skip to content

Commit

Permalink
Merge pull request #663 from maschwenk/dont-mutate-options
Browse files Browse the repository at this point in the history
[BUG] Don't mutate passed configuration options
  • Loading branch information
robin850 committed Jan 26, 2019
2 parents 92a7b3a + fc52d9c commit 3100f65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ext/redcarpet/rc_markdown.c
Expand Up @@ -115,8 +115,8 @@ static VALUE rb_redcarpet_md__new(int argc, VALUE *argv, VALUE klass)

/* Merge the current options in the @options hash */
if (hash != Qnil) {
rndr_options = rb_iv_get(rb_rndr, "@options");
rb_funcall(rndr_options, rb_intern("merge!"), 1, hash);
rndr_options = rb_funcall(rb_iv_get(rb_rndr, "@options"), rb_intern("merge"), 1, hash);
rb_iv_set(rb_rndr, "@options", rndr_options);
}

markdown = sd_markdown_new(extensions, 16, &rndr->callbacks, &rndr->options);
Expand Down
2 changes: 1 addition & 1 deletion test/custom_render_test.rb
Expand Up @@ -23,7 +23,7 @@ def test_simple_overload
end

def test_renderer_options
parser = Redcarpet::Markdown.new(SimpleRender.new(with_toc_data: true))
parser = Redcarpet::Markdown.new(SimpleRender.new({ with_toc_data: true }.freeze), {})
output = parser.render("# A title")

assert_match "My little poney", output
Expand Down

0 comments on commit 3100f65

Please sign in to comment.