aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index d5630bcdfe..5a07ebdc6e 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -148,11 +148,12 @@ module ActionView
build_observer('Form.Observer', form_id, options)
end
- private
+ # Escape carrier returns and single and double quotes for Javascript segments.
def escape_javascript(javascript)
- (javascript || '').gsub('"', '\"')
+ (javascript || '').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end
-
+
+ private
def options_for_ajax(options)
js_options = build_callbacks(options)