Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Don't mutate passed configuration options #663

Merged
merged 2 commits into from
Jan 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/redcarpet/rc_markdown.c
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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