aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/decoding.rb
diff options
context:
space:
mode:
authorUbiratan Pires Alberton <u.alberton@gmail.com>2009-03-11 06:12:08 -0300
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-11 14:36:14 -0700
commit7b382cb9e5c5706f8d15216159a2873375915c9c (patch)
tree9c21c1e251e5269920648e799c30f01ca27805c0 /activesupport/lib/active_support/json/decoding.rb
parentf2c7508befb085ffe19ec7fb9ca2e6919cc919c9 (diff)
downloadrails-7b382cb9e5c5706f8d15216159a2873375915c9c.tar.gz
rails-7b382cb9e5c5706f8d15216159a2873375915c9c.tar.bz2
rails-7b382cb9e5c5706f8d15216159a2873375915c9c.zip
Reverted affe50105f7027a44eb6e9cfb56f5b3fc070b19b and added more JSON decoding tests.
Works on Ruby 1.8 and 1.9 [#1100 state:resolved] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activesupport/lib/active_support/json/decoding.rb')
-rw-r--r--activesupport/lib/active_support/json/decoding.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/json/decoding.rb b/activesupport/lib/active_support/json/decoding.rb
index 198f3fd624..0e079341ff 100644
--- a/activesupport/lib/active_support/json/decoding.rb
+++ b/activesupport/lib/active_support/json/decoding.rb
@@ -59,7 +59,16 @@ module ActiveSupport
output = []
left_pos.each_with_index do |left, i|
scanner.pos = left.succ
- output << scanner.peek(right_pos[i] - scanner.pos + 1)
+ output << scanner.peek(right_pos[i] - scanner.pos + 1).gsub(/\\([\\\/]|u[[:xdigit:]]{4})/) do
+ ustr = $1
+ if ustr.starts_with?('u')
+ [ustr[1..-1].to_i(16)].pack("U")
+ elsif ustr == '\\'
+ '\\\\'
+ else
+ ustr
+ end
+ end
end
output = output * " "