mirror of
https://github.com/github/rails.git
synced 2026-01-29 00:08:15 -05:00
Ensure observe_field encodes value parameter. [#216 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
committed by
Pratik Naik
parent
c1c1d6c2ea
commit
17d1319c48
@@ -1068,7 +1068,7 @@ module ActionView
|
||||
|
||||
def build_observer(klass, name, options = {})
|
||||
if options[:with] && (options[:with] !~ /[\{=(.]/)
|
||||
options[:with] = "'#{options[:with]}=' + value"
|
||||
options[:with] = "'#{options[:with]}=' + encodeURIComponent(value)"
|
||||
else
|
||||
options[:with] ||= 'value' unless options[:function]
|
||||
end
|
||||
|
||||
@@ -219,9 +219,9 @@ class PrototypeHelperTest < PrototypeHelperBaseTest
|
||||
end
|
||||
|
||||
def test_observe_field_using_with_option
|
||||
expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:'id=' + value})})\n//]]>\n</script>)
|
||||
expected = %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/check_value', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(value)})})\n//]]>\n</script>)
|
||||
assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => 'id')
|
||||
assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "'id=' + value")
|
||||
assert_dom_equal expected, observe_field("glass", :frequency => 5.minutes, :url => { :action => "check_value" }, :with => "'id=' + encodeURIComponent(value)")
|
||||
end
|
||||
|
||||
def test_observe_field_using_json_in_with_option
|
||||
|
||||
Reference in New Issue
Block a user