summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-18 03:05:02 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-12-18 03:05:02 +0000
commit9f688d53c2b5af5960d1e8d8fb09b26aa9d8b5f9 (patch)
treed1253df0647f4a5477ea22758e29c10c1137a0a9 /ext
parent07fa1c9144aaf58414df1a27c06fb4a78683717d (diff)
* ext/psych/lib/psych/scalar_scanner.rb: Strings that look like dates
should be treated as strings and not dates. * test/psych/test_scalar_scanner.rb: corresponding tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/psych/lib/psych/scalar_scanner.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/psych/lib/psych/scalar_scanner.rb b/ext/psych/lib/psych/scalar_scanner.rb
index a265a2baf3..fa2d385a63 100644
--- a/ext/psych/lib/psych/scalar_scanner.rb
+++ b/ext/psych/lib/psych/scalar_scanner.rb
@@ -46,9 +46,13 @@ module Psych
end
when TIME
parse_time string
- when /^\d{4}-\d{1,2}-\d{1,2}$/
+ when /^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/
require 'date'
- Date.strptime(string, '%Y-%m-%d')
+ begin
+ Date.strptime(string, '%Y-%m-%d')
+ rescue ArgumentError
+ string
+ end
when /^\.inf$/i
1 / 0.0
when /^-\.inf$/i