From 2c564cdbdbe62c319e65abb3631b288f11878987 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Wed, 4 Dec 2013 09:43:42 -0800 Subject: Added \u2028 \u2029 to json_escape --- actionview/CHANGELOG.md | 3 +++ actionview/test/template/erb_util_test.rb | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 65d045d1f7..9e58c193b1 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,4 +1,7 @@ * Fixed a long-standing bug in `json_escape` that causes quotation marks to be stripped. + This method also escapes the \u2028 and \u2029 unicode newline characters which are + treated as \n in JavaScript. This matches the behaviour of the AS::JSON encoder. (The + original change in the encoder was introduced in #10534.) *Godfrey Chan* diff --git a/actionview/test/template/erb_util_test.rb b/actionview/test/template/erb_util_test.rb index 62067ad097..9bacbba908 100644 --- a/actionview/test/template/erb_util_test.rb +++ b/actionview/test/template/erb_util_test.rb @@ -33,7 +33,8 @@ class ErbUtilTest < ActiveSupport::TestCase ['"&"', '"\u0026"'], ['""', '"\u003c/script\u003e"'], ['[""]', '["\u003c/script\u003e"]'], - ['{"name":""}', '{"name":"\u003c/script\u003e"}'] + ['{"name":""}', '{"name":"\u003c/script\u003e"}'], + [%({"name":"d\u2028h\u2029h"}), '{"name":"d\u2028h\u2029h"}'] ] def test_html_escape -- cgit v1.2.3