Skip to content

Commit

Permalink
Fix remote_function to escape apostrophes inside the remote url passe…
Browse files Browse the repository at this point in the history
…d to Ajax.Update. [#180 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information
indirect authored and lifo committed May 13, 2008
1 parent 3fee237 commit d16fbe5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/prototype_helper.rb
Expand Up @@ -458,7 +458,7 @@ def remote_function(options)

url_options = options[:url]
url_options = url_options.merge(:escape => false) if url_options.is_a?(Hash)
function << "'#{url_for(url_options)}'"
function << "'#{escape_javascript(url_for(url_options))}'"
function << ", #{javascript_options})"

function = "#{options[:before]}; #{function}" if options[:before]
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/template/prototype_helper_test.rb
Expand Up @@ -86,6 +86,11 @@ def test_link_to_remote_html_options
link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :html => { :class => "fine" } })
end

def test_link_to_remote_url_quote_escaping
assert_dom_equal %(<a href="#" onclick="new Ajax.Request('http://www.example.com/whatnot\\\'s', {asynchronous:true, evalScripts:true}); return false;">Remote</a>),
link_to_remote("Remote", { :url => { :action => "whatnot's" } })
end

def test_periodically_call_remote
assert_dom_equal %(<script type="text/javascript">\n//<![CDATA[\nnew PeriodicalExecuter(function() {new Ajax.Updater('schremser_bier', 'http://www.example.com/mehr_bier', {asynchronous:true, evalScripts:true})}, 10)\n//]]>\n</script>),
periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" })
Expand Down

1 comment on commit d16fbe5

@technomancy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, now you can come to CabooseConf. =)

Please sign in to comment.