aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/backends/yajl.rb
diff options
context:
space:
mode:
authorJosh Kalderimis <josh.kalderimis@gmail.com>2011-02-11 16:47:25 +0100
committerSantiago Pastorino <santiago@wyeworks.com>2011-02-11 13:54:57 -0200
commitb17d8d727fb510ad8b6eb4302984d290dc2e53b0 (patch)
treef482fbd339de6f1bbdbf38d9a07c119f6e18d119 /activesupport/lib/active_support/json/backends/yajl.rb
parentf23bf7dbdbc0e0590083f0f288aa24f5b830e685 (diff)
downloadrails-b17d8d727fb510ad8b6eb4302984d290dc2e53b0.tar.gz
rails-b17d8d727fb510ad8b6eb4302984d290dc2e53b0.tar.bz2
rails-b17d8d727fb510ad8b6eb4302984d290dc2e53b0.zip
Fixes an issue when decoding a json string which looks like a date but is invalid. This DateTime parse error is now caught and the original string is instead passed back [#6286 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/lib/active_support/json/backends/yajl.rb')
-rw-r--r--activesupport/lib/active_support/json/backends/yajl.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/json/backends/yajl.rb b/activesupport/lib/active_support/json/backends/yajl.rb
index 64e50e0d87..58818658c7 100644
--- a/activesupport/lib/active_support/json/backends/yajl.rb
+++ b/activesupport/lib/active_support/json/backends/yajl.rb
@@ -23,7 +23,11 @@ module ActiveSupport
when nil
nil
when DATE_REGEX
- DateTime.parse(data)
+ begin
+ DateTime.parse(data)
+ rescue ArgumentError
+ data
+ end
when Array
data.map! { |d| convert_dates_from(d) }
when Hash