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

Ticket #8425: json_decode_alternating_quote_types_with_test.diff

File json_decode_alternating_quote_types_with_test.diff, 1.0 kB (added by deepblue, 2 years ago)

I added a unit test for this case.

  • activesupport/test/json/decoding_test.rb

    old new  
    1313    %(1)     => 1, 
    1414    %("")    => "", 
    1515    %("\\"") => "\"", 
     16    %("'':") => "'':", 
    1617    %(null)  => nil, 
    1718    %(true)  => true, 
    1819    %(false) => false 
  • activesupport/lib/active_support/json/decoding.rb

    old new  
    2222          while scanner.scan_until(/(['":,]|\\.)/) 
    2323            case char = scanner[1] 
    2424            when '"', "'" 
    25               quoting = quoting == char ? false : char 
     25              quoting = quoting == char ? false : (quoting ? quoting : char) 
    2626            when ":", "," 
    2727              marks << scanner.pos - 1 unless quoting 
    2828            end