[前][次][番号順一覧][スレッド一覧]

ruby-changes:31784

From: tenderlove <ko1@a...>
Date: Wed, 27 Nov 2013 04:48:12 +0900 (JST)
Subject: [ruby-changes:31784] tenderlove:r43863 (trunk): * ext/psych/lib/psych/scalar_scanner.rb: fix regexp for matching TIME

tenderlove	2013-11-27 04:48:03 +0900 (Wed, 27 Nov 2013)

  New Revision: 43863

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43863

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/scalar_scanner.rb
    trunk/test/psych/test_date_time.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43862)
+++ ChangeLog	(revision 43863)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov 27 04:46:55 2013  Aaron Patterson <aaron@t...>
+
+	* 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  <nobu@r...>
 
 	* string.c (str_new4): copy the original capacity so that memsize of
Index: ext/psych/lib/psych/scalar_scanner.rb
===================================================================
--- ext/psych/lib/psych/scalar_scanner.rb	(revision 43862)
+++ ext/psych/lib/psych/scalar_scanner.rb	(revision 43863)
@@ -5,7 +5,7 @@ module Psych https://github.com/ruby/ruby/blob/trunk/ext/psych/lib/psych/scalar_scanner.rb#L5
   # 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)
Index: test/psych/test_date_time.rb
===================================================================
--- test/psych/test_date_time.rb	(revision 43862)
+++ test/psych/test_date_time.rb	(revision 43863)
@@ -3,6 +3,10 @@ require 'date' https://github.com/ruby/ruby/blob/trunk/test/psych/test_date_time.rb#L3
 
 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]