Skip to content

Error when serializing date string with non-space whitespace character #691

@kkan

Description

@kkan
string = "2023-12-30\t23:16:25"
Psych.dump(string)
/.rbenv/versions/3.2.2/lib/ruby/3.2.0/psych/scalar_scanner.rb:120:in `parse_time': undefined method `match' for nil:NilClass (NoMethodError)

      md = time.match(/(\d+:\d+:\d+)(?:\.(\d*))?\s*(Z|[-+]\d+(:\d\d)?)?/)

Happens because \s is used in TIME regex, and space is used when splitting string into date and time

string.match?(Psych::ScalarScanner::TIME) # true
date, time = *(string.split(/[ tT]/, 2)) # ["2023-12-30\t23:16:25"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions