Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5242

Show
Ignore:
Timestamp:
10/09/06 00:34:43 (2 years ago)
Author:
david
Message:

Fixed escaping of backslashes in JavaScriptHelper#escape_javascript (closes #6302) [sven@c3d2.de]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r5241 r5242  
    11*SVN* 
     2 
     3* Fixed escaping of backslashes in JavaScriptHelper#escape_javascript #6302 [sven@c3d2.de] 
    24 
    35* Fixed that some 500 rescues would cause 500's themselves because the response had not yet been generated #6329 [cmselmer] 
  • trunk/actionpack/lib/action_view/helpers/javascript_helper.rb

    r5238 r5242  
    150150      # Escape carrier returns and single and double quotes for JavaScript segments. 
    151151      def escape_javascript(javascript) 
    152         (javascript || '').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" } 
     152        (javascript || '').gsub('\\','\0\0').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" } 
    153153      end 
    154154 
  • trunk/actionpack/test/template/javascript_helper_test.rb

    r5039 r5242  
    2020  def test_escape_javascript 
    2121    assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos')) 
     22    assert_equal %(backslash\\\\test), escape_javascript( %(backslash\\test) ) 
    2223  end 
    2324