aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-01-21 14:09:59 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-01-21 14:09:59 -0800
commit370bcd1a017816422db2fdb410366752d60d72c8 (patch)
tree546bf18cfcdc7aa6ec5b65c24718d150d534d9ed /activesupport
parent7642b7531d222c9d7a94add50fffca69458e0eef (diff)
downloadrails-370bcd1a017816422db2fdb410366752d60d72c8.tar.gz
rails-370bcd1a017816422db2fdb410366752d60d72c8.tar.bz2
rails-370bcd1a017816422db2fdb410366752d60d72c8.zip
use ! " " YAML string literal syntax rather than removing both quotes
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/json/backends/yaml.rb8
-rw-r--r--activesupport/test/json/decoding_test.rb4
2 files changed, 5 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/json/backends/yaml.rb b/activesupport/lib/active_support/json/backends/yaml.rb
index 2e389b5c12..c7ed931c1b 100644
--- a/activesupport/lib/active_support/json/backends/yaml.rb
+++ b/activesupport/lib/active_support/json/backends/yaml.rb
@@ -20,8 +20,8 @@ module ActiveSupport
json = json.read
end
YAML.load(convert_json_to_yaml(json))
- rescue *EXCEPTIONS
- raise ParseError, "Invalid JSON string"
+ rescue *EXCEPTIONS => e
+ raise ParseError, "Invalid JSON string: '%s'" % json
end
protected
@@ -39,7 +39,7 @@ module ActiveSupport
if json[pos..scanner.pos-2] =~ DATE_REGEX
# found a date, track the exact positions of the quotes so we can
# overwrite them with spaces later.
- times << pos << scanner.pos
+ times << pos
end
quoting = false
end
@@ -70,7 +70,7 @@ module ActiveSupport
chunk = scanner.peek(right_pos[i] - scanner.pos + 1)
# overwrite the quotes found around the dates with spaces
while times.size > 0 && times[0] <= right_pos[i]
- chunk[times.shift - scanner.pos - 1] = ' '
+ chunk.insert(times.shift - scanner.pos - 1, '! ')
end
chunk.gsub!(/\\([\\\/]|u[[:xdigit:]]{4})/) do
ustr = $1
diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb
index d2e3efaa6b..a0beb97537 100644
--- a/activesupport/test/json/decoding_test.rb
+++ b/activesupport/test/json/decoding_test.rb
@@ -57,9 +57,7 @@ class TestJSONDecoding < ActiveSupport::TestCase
ActiveSupport.parse_json_times = true
silence_warnings do
ActiveSupport::JSON.with_backend backend do
- assert_nothing_raised do
- assert_equal expected, ActiveSupport::JSON.decode(json)
- end
+ assert_equal expected, ActiveSupport::JSON.decode(json)
end
end
end