psych icon indicating copy to clipboard operation
psych copied to clipboard

Dates with 5 digit years can not deserialized

Open krisleech opened this issue 4 years ago • 2 comments

require 'time'
require 'yaml'

date = DateTime.parse('22018-01-05')
serialized_date = YAML.dump(date)
YAML.load(serialized_date)
# => fails with NoMethodError: undefined method `captures' for nil:NilClass

This is because the regex for parsing a Date, in ScalarScanner, expects a 4 digit year.

The year is actually incorrect and should have been validated before being saved. It has made it in to our data.

Please close if you think this is too much of an edge case to be considered.

On the other hand 5 digit years are legit.

krisleech avatar Apr 06 '21 15:04 krisleech

Hi @krisleech, I think the issue is on Line number 112 but here your mentioned Line number 113.

AravindSelvamani avatar Sep 07 '21 08:09 AravindSelvamani