diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-13 00:00:26 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-13 00:00:26 +0000 |
commit | b5f05971f5349753966067e9af2555801a32c1ac (patch) | |
tree | 738b80c75ae3cd43c6f74ab6f308d8c73d973d92 /ext | |
parent | e8b3d0decfa58776fab3492ae6406e58ad60a05c (diff) | |
download | ruby-b5f05971f5349753966067e9af2555801a32c1ac.tar.gz |
* ext/psych/lib/psych/scalar_scanner.rb: Only consider strings
with fewer than 2 dots to be numbers. [ruby-core:38915]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/psych/lib/psych/scalar_scanner.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb index 29d66ee4cc..b92d3c075e 100644 --- a/ext/psych/lib/psych/scalar_scanner.rb +++ b/ext/psych/lib/psych/scalar_scanner.rb @@ -68,8 +68,11 @@ module Psych end i else - return Integer(string.gsub(/[,_]/, '')) rescue ArgumentError - return Float(string.gsub(/[,_]/, '')) rescue ArgumentError + if string.count('.') < 2 + return Integer(string.gsub(/[,_]/, '')) rescue ArgumentError + return Float(string.gsub(/[,_]/, '')) rescue ArgumentError + end + @string_cache[string] = true string end |