diff --git a/ChangeLog b/ChangeLog index 7e6a971283..8029e9f63d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Nov 27 04:46:55 2013 Aaron Patterson + + * 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 27 02:26:58 2013 Nobuyoshi Nakada * string.c (str_new4): copy the original capacity so that memsize of diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb index 068fc0e3cf..5a805981b1 100644 --- a/ext/psych/lib/psych/scalar_scanner.rb +++ b/ext/psych/lib/psych/scalar_scanner.rb @@ -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) diff --git a/test/psych/test_date_time.rb b/test/psych/test_date_time.rb index 9a8e37bc67..91de6a4841 100644 --- a/test/psych/test_date_time.rb +++ b/test/psych/test_date_time.rb @@ -3,6 +3,10 @@ require 'date' 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