From 92f02adf407d6884ffea789b39f78f44b7fd3722 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sun, 2 Dec 2007 08:45:35 +0000 Subject: Don't escape forward slashes with String#to_json, our unicode encoding of < and > prevent the XSS problems. [tpope] Closes #10273 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8255 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/template/prototype_helper_test.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'actionpack/test/template/prototype_helper_test.rb') diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb index 6caf67810c..3978722419 100644 --- a/actionpack/test/template/prototype_helper_test.rb +++ b/actionpack/test/template/prototype_helper_test.rb @@ -303,23 +303,23 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase end def test_insert_html_with_string - assert_equal 'new Insertion.Top("element", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E");', + assert_equal 'new Insertion.Top("element", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E");', @generator.insert_html(:top, 'element', '

This is a test

') - assert_equal 'new Insertion.Bottom("element", "\\u003Cp\u003EThis is a test\\u003C\\/p\u003E");', + assert_equal 'new Insertion.Bottom("element", "\\u003Cp\u003EThis is a test\\u003C/p\u003E");', @generator.insert_html(:bottom, 'element', '

This is a test

') - assert_equal 'new Insertion.Before("element", "\\u003Cp\u003EThis is a test\\u003C\\/p\u003E");', + assert_equal 'new Insertion.Before("element", "\\u003Cp\u003EThis is a test\\u003C/p\u003E");', @generator.insert_html(:before, 'element', '

This is a test

') - assert_equal 'new Insertion.After("element", "\\u003Cp\u003EThis is a test\\u003C\\/p\u003E");', + assert_equal 'new Insertion.After("element", "\\u003Cp\u003EThis is a test\\u003C/p\u003E");', @generator.insert_html(:after, 'element', '

This is a test

') end def test_replace_html_with_string - assert_equal 'Element.update("element", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E");', + assert_equal 'Element.update("element", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E");', @generator.replace_html('element', '

This is a test

') end def test_replace_element_with_string - assert_equal 'Element.replace("element", "\\u003Cdiv id=\"element\"\\u003E\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E\\u003C\\/div\\u003E");', + assert_equal 'Element.replace("element", "\\u003Cdiv id=\"element\"\\u003E\\u003Cp\\u003EThis is a test\\u003C/p\\u003E\\u003C/div\\u003E");', @generator.replace('element', '

This is a test

') end @@ -356,7 +356,7 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase end def test_redirect_to - assert_equal 'window.location.href = "http:\\/\\/www.example.com\\/welcome";', + assert_equal 'window.location.href = "http://www.example.com/welcome";', @generator.redirect_to(:action => 'welcome') end @@ -375,10 +375,10 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase @generator.replace_html('baz', '

This is a test

') assert_equal <<-EOS.chomp, @generator.to_s -new Insertion.Top("element", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E"); -new Insertion.Bottom("element", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E"); +new Insertion.Top("element", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E"); +new Insertion.Bottom("element", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E"); ["foo", "bar"].each(Element.remove); -Element.update("baz", "\\u003Cp\\u003EThis is a test\\u003C\\/p\\u003E"); +Element.update("baz", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E"); EOS end -- cgit v1.2.3