aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAna María Martínez Gómez <anamma06@gmail.com>2018-08-07 17:23:57 +0200
committerAna María Martínez Gómez <ammartinez@suse.de>2018-08-07 17:45:12 +0200
commit87b6e6aa4328f16edd68978079f473169cceecbd (patch)
tree9391a0f38f159a1009ea04a4f6735f586e09d969
parentb9807eb53880a386890aa1919cf812fb9876b805 (diff)
downloadrails-87b6e6aa4328f16edd68978079f473169cceecbd.tar.gz
rails-87b6e6aa4328f16edd68978079f473169cceecbd.tar.bz2
rails-87b6e6aa4328f16edd68978079f473169cceecbd.zip
Use public_send in value_for_collection
Avoid exposing private methods in view's helpers. Fixes https://github.com/rails/rails/issues/33546
-rw-r--r--actionview/CHANGELOG.md10
-rw-r--r--actionview/lib/action_view/helpers/form_options_helper.rb2
2 files changed, 11 insertions, 1 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md
index 6d45cc1d8a..8597fea48d 100644
--- a/actionview/CHANGELOG.md
+++ b/actionview/CHANGELOG.md
@@ -1,3 +1,13 @@
+* 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
diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb
index 7884a8d997..9c0238a01a 100644
--- a/actionview/lib/action_view/helpers/form_options_helper.rb
+++ b/actionview/lib/action_view/helpers/form_options_helper.rb
@@ -802,7 +802,7 @@ module ActionView
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)