Skip to content

Commit

Permalink
Fixed that single quote was not escaped in a UrlHelper#link_to javasc…
Browse files Browse the repository at this point in the history
…ript confirm rails#549 [Scott Barron]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@837 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Mar 6, 2005
1 parent eb5ca2e commit 25b656f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Fixed that single quote was not escaped in a UrlHelper#link_to javascript confirm #549 [Scott Barron]

* Removed the default border on link_image_to (it broke xhtml strict) -- can be specified with :border => 0 #517 [?/caleb]

* Fixed that form helpers would treat string and symbol keys differently in html_options (and possibly create duplicate entries) #112 [bitsweat]
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/url_helper.rb
Expand Up @@ -138,7 +138,7 @@ def current_page?(options)
private
def convert_confirm_option_to_javascript!(html_options)
if confirm = html_options.delete("confirm")
html_options["onclick"] = "return confirm('#{confirm}');"
html_options["onclick"] = "return confirm('#{confirm.gsub(/'/, '\\\\\'')}');"
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions actionpack/test/template/url_helper_test.rb
Expand Up @@ -27,6 +27,10 @@ def test_link_tag_with_javascript_confirm
"<a href=\"http://www.world.com\" onclick=\"return confirm('Are you sure?');\">Hello</a>",
link_to("Hello", "http://www.world.com", :confirm => "Are you sure?")
)
assert_equal(
"<a href=\"http://www.world.com\" onclick=\"return confirm('You can\\'t possibly be sure, can you?');\">Hello</a>",
link_to("Hello", "http://www.world.com", :confirm => "You can't possibly be sure, can you?")
)
end

def test_link_image_to
Expand Down

0 comments on commit 25b656f

Please sign in to comment.