Skip to content
This repository
Browse code

Fix JSON decoder date-converter regexp [#1662 state:resolved] [Jonath…

…an del Strother]
  • Loading branch information...
commit 17da45b789e0a2581eae6e6b2b1ae8d2b98e0f5d 1 parent 2f92313
Pratik authored January 07, 2009
2  activesupport/lib/active_support/json/decoding.rb
@@ -16,7 +16,7 @@ def decode(json)
16 16
       
17 17
       protected
18 18
         # matches YAML-formatted dates
19  
-        DATE_REGEX = /^\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?$/
  19
+        DATE_REGEX = /^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[ \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?)?)$/
20 20
 
21 21
         # Ensure that ":" and "," are always followed by a space
22 22
         def convert_json_to_yaml(json) #:nodoc:
3  activesupport/test/json/decoding_test.rb
@@ -15,7 +15,8 @@ class TestJSONDecoding < Test::Unit::TestCase
15 15
     # no time zone
16 16
     %({a: "2007-01-01 01:12:34"})              => {'a' => "2007-01-01 01:12:34"}, 
17 17
     # needs to be *exact*
18  
-    %({a: " 2007-01-01 01:12:34 Z "})          => {'a' => " 2007-01-01 01:12:34 Z "}, 
  18
+    %({a: " 2007-01-01 01:12:34 Z "})          => {'a' => " 2007-01-01 01:12:34 Z "},
  19
+    %({a: "2007-01-01 : it's your birthday"})  => {'a' => "2007-01-01 : it's your birthday"},
19 20
     %([])    => [],
20 21
     %({})    => {},
21 22
     %(1)     => 1,

0 notes on commit 17da45b

Please sign in to comment.
Something went wrong with that request. Please try again.