summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-07 11:33:39 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-07 11:33:39 +0000
commite115627a1846d2c15d1319e6399fa5f8d6e5cb61 (patch)
tree27233e348a8ae0366c376c0e6d5a63c071421fe2
parent8ff37e390195f401d82cc8cfb607a3b2ddcba1ed (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--ext/psych/lib/psych/scalar_scanner.rb2
-rw-r--r--test/psych/test_string.rb6
3 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a61c9d7df08..35a83a1a54f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Nov 7 20:31:52 2011 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * 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@tenderlovemaking.com>
* test/psych/test_yamlstore.rb: make test case inherit from MiniTest,
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb
index e390cbb16a1..a265a2baf3a 100644
--- a/ext/psych/lib/psych/scalar_scanner.rb
+++ b/ext/psych/lib/psych/scalar_scanner.rb
@@ -61,7 +61,7 @@ module Psych
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)
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb
index 51f1280abfb..cffc12163b5 100644
--- a/test/psych/test_string.rb
+++ b/test/psych/test_string.rb
@@ -2,6 +2,12 @@ require 'psych/helper'
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'