Changeset 8050
- Timestamp:
- 10/29/07 00:18:43 (1 year ago)
- Files:
-
- trunk/actionpack/test/template/javascript_helper_test.rb (modified) (4 diffs)
- trunk/actionpack/test/template/prototype_helper_test.rb (modified) (2 diffs)
- trunk/activerecord/test/serialization_test.rb (modified) (1 diff)
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/json/encoders/string.rb (modified) (2 diffs)
- trunk/activesupport/test/json/encoding_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/test/template/javascript_helper_test.rb
r8034 r8050 39 39 page.replace_html 'header', "<h1>Greetings</h1>" 40 40 end 41 assert_dom_equal %(<a href="#" onclick="Element.update("header", "\\ 074h1\\076Greetings\\074\\/h1\\076");; return false;">Greet me!</a>), html41 assert_dom_equal %(<a href="#" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C\\/h1\\u003E");; return false;">Greet me!</a>), html 42 42 end 43 43 … … 46 46 page.replace_html 'header', "<h1>Greetings</h1>" 47 47 end 48 assert_dom_equal %(<a href="#" class="updater" onclick="Element.update("header", "\\ 074h1\\076Greetings\\074\\/h1\\076");; return false;">Greet me!</a>), html48 assert_dom_equal %(<a href="#" class="updater" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C\\/h1\\u003E");; return false;">Greet me!</a>), html 49 49 end 50 50 … … 68 68 page.replace_html 'header', "<h1>Greetings</h1>" 69 69 end 70 assert_dom_equal %(<input type="button" onclick="Element.update("header", "\\ 074h1\\076Greetings\\074\\/h1\\076");;" value="Greet me!" />), html70 assert_dom_equal %(<input type="button" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C\\/h1\\u003E");;" value="Greet me!" />), html 71 71 end 72 72 … … 75 75 page.replace_html 'header', "<h1>Greetings</h1>" 76 76 end 77 assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update("header", "\\ 074h1\\076Greetings\\074\\/h1\\076");;" value="Greet me!" />), html77 assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update("header", "\\u003Ch1\\u003EGreetings\\u003C\\/h1\\u003E");;" value="Greet me!" />), html 78 78 end 79 79 trunk/actionpack/test/template/prototype_helper_test.rb
r8034 r8050 304 304 305 305 def test_insert_html_with_string 306 assert_equal 'new Insertion.Top("element", "\\ 074p\\076This is a test\\074\\/p\\076");',306 assert_equal 'new Insertion.Top("element", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E");', 307 307 @generator.insert_html(:top, 'element', '<p>This is a test</p>') 308 assert_equal 'new Insertion.Bottom("element", "\\ 074p\076This is a test\\074\\/p\076");',308 assert_equal 'new Insertion.Bottom("element", "\\u003Cp\u003EThis is a test\\u003C\\/p\u003E");', 309 309 @generator.insert_html(:bottom, 'element', '<p>This is a test</p>') 310 assert_equal 'new Insertion.Before("element", "\\ 074p\076This is a test\\074\\/p\076");',310 assert_equal 'new Insertion.Before("element", "\\u003Cp\u003EThis is a test\\u003C\\/p\u003E");', 311 311 @generator.insert_html(:before, 'element', '<p>This is a test</p>') 312 assert_equal 'new Insertion.After("element", "\\ 074p\076This is a test\\074\\/p\076");',312 assert_equal 'new Insertion.After("element", "\\u003Cp\u003EThis is a test\\u003C\\/p\u003E");', 313 313 @generator.insert_html(:after, 'element', '<p>This is a test</p>') 314 314 end 315 315 316 316 def test_replace_html_with_string 317 assert_equal 'Element.update("element", "\\ 074p\\076This is a test\\074\\/p\\076");',317 assert_equal 'Element.update("element", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E");', 318 318 @generator.replace_html('element', '<p>This is a test</p>') 319 319 end 320 320 321 321 def test_replace_element_with_string 322 assert_equal 'Element.replace("element", "\\ 074div id=\"element\"\\076\\074p\\076This is a test\\074\\/p\\076\\074\\/div\\076");',322 assert_equal 'Element.replace("element", "\\u003Cdiv id=\"element\"\\u003E\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E\\u003C\\/div\\u003E");', 323 323 @generator.replace('element', '<div id="element"><p>This is a test</p></div>') 324 324 end … … 376 376 377 377 assert_equal <<-EOS.chomp, @generator.to_s 378 new Insertion.Top("element", "\\ 074p\\076This is a test\\074\\/p\\076");379 new Insertion.Bottom("element", "\\ 074p\\076This is a test\\074\\/p\\076");378 new Insertion.Top("element", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E"); 379 new Insertion.Bottom("element", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E"); 380 380 ["foo", "bar"].each(Element.remove); 381 Element.update("baz", "\\ 074p\\076This is a test\\074\\/p\\076");381 Element.update("baz", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E"); 382 382 EOS 383 383 end trunk/activerecord/test/serialization_test.rb
r7519 r8050 12 12 :created_at => Time.utc(2006, 8, 1), 13 13 :awesome => false, 14 :preferences => { :gem => ' ruby' }14 :preferences => { :gem => '<strong>ruby</strong>' } 15 15 } 16 16 trunk/activesupport/CHANGELOG
r8026 r8050 1 1 *SVN* 2 3 * Change JSON to encode %w(< > &) as 4 digit hex codes to be in compliance with the JSON spec. Closes #9975 [josh, chuyeow, tpope] 2 4 3 5 * Fix JSON encoding/decoding bugs dealing with /'s. Closes #9990 [Rick, theamazingrando] trunk/activesupport/lib/active_support/json/encoders/string.rb
r8026 r8050 10 10 '"' => '\"', 11 11 '\\' => '\\\\', 12 ">" => '\076', 13 '<' => '\074', 12 '>' => '\u003E', 13 '<' => '\u003C', 14 '&' => '\u0026', 14 15 '/' => '\\/' 15 16 } … … 20 21 class String 21 22 def to_json(options = nil) #:nodoc: 22 '"' + gsub(/[\010\f\n\r\t"\\>< \/]/) { |s|23 '"' + gsub(/[\010\f\n\r\t"\\><&\/]/) { |s| 23 24 ActiveSupport::JSON::Encoding::ESCAPED_CHARS[s] 24 25 }.gsub(/([\xC0-\xDF][\x80-\xBF]| trunk/activesupport/test/json/encoding_test.rb
r8026 r8050 14 14 [ 2.5, %(2.5) ]] 15 15 16 StringTests = [[ 'this is the <string>', %("this is the \\ 074string\\076")],17 [ 'a "string" with quotes ', %("a \\"string\\" with quotes") ],16 StringTests = [[ 'this is the <string>', %("this is the \\u003Cstring\\u003E")], 17 [ 'a "string" with quotes & an ampersand', %("a \\"string\\" with quotes \\u0026 an ampersand") ], 18 18 [ 'http://test.host/posts/1', %("http:\\/\\/test.host\\/posts\\/1")]] 19 19