Changeset 7506
- Timestamp:
- 09/17/07 21:37:48 (1 year ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/json/decoding.rb (modified) (1 diff)
- trunk/activesupport/test/json/decoding_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r7505 r7506 1 1 *SVN* 2 3 * Fix JSON decoder with nested quotes and commas. #9579 [zdennis] 2 4 3 5 * Hash#to_xml doesn't double-unescape. #8806 [Ezran] trunk/activesupport/lib/active_support/json/decoding.rb
r6443 r7506 16 16 17 17 protected 18 18 19 # Ensure that ":" and "," are always followed by a space 19 20 def convert_json_to_yaml(json) #:nodoc: 20 21 scanner, quoting, marks = StringScanner.new(json), false, [] 21 22 22 while scanner.scan_until(/( ['":,]|\\.)/)23 while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/) 23 24 case char = scanner[1] 24 25 when '"', "'" 25 quoting = quoting == char ? false : char 26 when ":", "," 26 if !quoting 27 quoting = char 28 elsif quoting == char 29 quoting = false 30 end 31 when ":","," 27 32 marks << scanner.pos - 1 unless quoting 28 33 end 29 34 end 30 35 31 36 if marks.empty? 32 37 json trunk/activesupport/test/json/decoding_test.rb
r7117 r7506 9 9 %({"returnTo":[1,"a"]}) => {"returnTo" => [1, "a"]}, 10 10 %({"returnTo":[1,"\\"a\\",", "b"]}) => {"returnTo" => [1, "\"a\",", "b"]}, 11 %({a: "'", "b": "5,000"}) => {"a" => "'", "b" => "5,000"}, 12 %({a: "a's, b's and c's", "b": "5,000"}) => {"a" => "a's, b's and c's", "b" => "5,000"}, 11 13 %([]) => [], 12 14 %({}) => {},