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

ruby-changes:21606

From: tenderlove <ko1@a...>
Date: Mon, 7 Nov 2011 20:33:49 +0900 (JST)
Subject: [ruby-changes:21606] tenderlove:r33655 (trunk): * ext/psych/lib/psych/scalar_scanner.rb: make sure strings that look

tenderlove	2011-11-07 20:33:39 +0900 (Mon, 07 Nov 2011)

  New Revision: 33655

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

  Log:
    * ext/psych/lib/psych/scalar_scanner.rb: make sure strings that look
      like base 60 numbers are serialized as quoted strings.
    * test/psych/test_string.rb: test for change.

  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/scalar_scanner.rb
    trunk/test/psych/test_string.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33654)
+++ ChangeLog	(revision 33655)
@@ -1,3 +1,9 @@
+Mon Nov  7 20:31:52 2011  Aaron Patterson <aaron@t...>
+
+	* ext/psych/lib/psych/scalar_scanner.rb: make sure strings that look
+	  like base 60 numbers are serialized as quoted strings.
+	* test/psych/test_string.rb: test for change.
+
 Mon Nov  7 20:26:37 2011  Aaron Patterson <aaron@t...>
 
 	* test/psych/test_yamlstore.rb: make test case inherit from MiniTest,
Index: ext/psych/lib/psych/scalar_scanner.rb
===================================================================
--- ext/psych/lib/psych/scalar_scanner.rb	(revision 33654)
+++ ext/psych/lib/psych/scalar_scanner.rb	(revision 33655)
@@ -61,7 +61,7 @@
         else
           string.sub(/^:/, '').to_sym
         end
-      when /^[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+$/
+      when /^[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+$/
         i = 0
         string.split(':').each_with_index do |n,e|
           i += (n.to_i * 60 ** (e - 2).abs)
Index: test/psych/test_string.rb
===================================================================
--- test/psych/test_string.rb	(revision 33654)
+++ test/psych/test_string.rb	(revision 33655)
@@ -2,6 +2,12 @@
 
 module Psych
   class TestString < TestCase
+    def test_string_with_base_60
+      yaml = Psych.dump '01:03:05'
+      assert_match "'01:03:05'", yaml
+      assert_equal '01:03:05', Psych.load(yaml)
+    end
+
     def test_tagged_binary_should_be_dumped_as_binary
       string = "hello world!"
       string.force_encoding 'ascii-8bit'

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

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