diff --git a/lib/psych/scalar_scanner.rb b/lib/psych/scalar_scanner.rb index 8cf868f8..23efffb7 100644 --- a/lib/psych/scalar_scanner.rb +++ b/lib/psych/scalar_scanner.rb @@ -114,7 +114,7 @@ def parse_int string def parse_time string klass = class_loader.load 'Time' - date, time = *(string.split(/[ tT]/, 2)) + date, time = *(string.split(/[Tt]|\s+/, 2)) (yy, m, dd) = date.match(/^(-?\d{4})-(\d{1,2})-(\d{1,2})/).captures.map { |x| x.to_i } md = time.match(/(\d+:\d+:\d+)(?:\.(\d*))?\s*(Z|[-+]\d+(:\d\d)?)?/) diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index cfd235a5..39731031 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -60,6 +60,11 @@ def test_single_quote_when_matching_date RUBY end + def test_datetime_string_with_tab_separator + str = "2023-12-31\t12:00:00" + assert_cycle str + end + def test_plain_when_shorten_than_line_width_and_no_final_line_break str = "Lorem ipsum" yaml = Psych.dump str, line_width: 12