summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/scalar_scanner.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/psych/lib/psych/scalar_scanner.rb')
-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