lib/active_support/json/backends/yaml.rb in activesupport-3.0.4 vs lib/active_support/json/backends/yaml.rb in activesupport-3.0.5.rc1
- old
+ new
@@ -27,11 +27,11 @@
when '"', "'"
if !quoting
quoting = char
pos = scanner.pos
elsif quoting == char
- if json[pos..scanner.pos-2] =~ DATE_REGEX
+ if valid_date?(json[pos..scanner.pos-2])
# found a date, track the exact positions of the quotes so we can
# overwrite them with spaces later.
times << pos << scanner.pos
end
quoting = false
@@ -81,9 +81,19 @@
output.gsub!(/\\\//, '/')
output
end
end
+
+ private
+ def valid_date?(date_string)
+ begin
+ date_string =~ DATE_REGEX && DateTime.parse(date_string)
+ rescue ArgumentError
+ false
+ end
+ end
+
end
end
end
end