Permalink
Browse files

fix regexp for matching TIME.

fixes #171
  • Loading branch information...
1 parent 1003a03 commit 6066fcc8d8d49ed22538cf33e2c3da61334d55b2 @tenderlove tenderlove committed Nov 26, 2013
Showing with 12 additions and 1 deletion.
  1. +7 −0 CHANGELOG.rdoc
  2. +1 −1 lib/psych/scalar_scanner.rb
  3. +4 −0 test/psych/test_date_time.rb
View
@@ -1,3 +1,10 @@
+Wed Nov 27 04:46:55 2013 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/scalar_scanner.rb: fix regexp for matching TIME
+ strings.
+ * test/psych/test_date_time.rb: test for change.
+ Fixes: https://github.com/tenderlove/psych/issues/171
+
Wed Nov 6 04:14:25 2013 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/to_ruby.rb: process merge keys before
@@ -5,7 +5,7 @@ module Psych
# Scan scalars for built in types
class ScalarScanner
# Taken from http://yaml.org/type/timestamp.html
- TIME = /^\d{4}-\d{1,2}-\d{1,2}([Tt]|\s+)\d{1,2}:\d\d:\d\d(\.\d*)?(\s*Z|[-+]\d{1,2}(:\d\d)?)?/
+ TIME = /^\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/
# Taken from http://yaml.org/type/float.html
FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10)
@@ -3,6 +3,10 @@
module Psych
class TestDateTime < TestCase
+ def test_invalid_date
+ assert_cycle "2013-10-31T10:40:07-000000000000033"
+ end
+
def test_string_tag
dt = DateTime.now
yaml = Psych.dump dt

0 comments on commit 6066fcc

Please sign in to comment.