提交 87b6e6aa 编写于 作者: A Ana María Martínez Gómez 提交者: Ana María Martínez Gómez

Use public_send in value_for_collection

Avoid exposing private methods in view's helpers.

Fixes https://github.com/rails/rails/issues/33546
上级 b9807eb5
* Stop exposing public methods in view's helpers.
For example, in methods like `options_from_collection_for_select`,
it was possible to call private methods from the objects used.
See [#33546](https://github.com/rails/rails/issues/33546) for details.
*[Ana María Martínez Gómez](https://github.com/Ana06)*
* Fix issue with `button_to`'s `to_form_params`
`button_to` was throwing exception when invoked with `params` hash that
......
......@@ -802,7 +802,7 @@ def extract_values_from_collection(collection, value_method, selected)
end
def value_for_collection(item, value)
value.respond_to?(:call) ? value.call(item) : item.send(value)
value.respond_to?(:call) ? value.call(item) : item.public_send(value)
end
def prompt_text(prompt)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册