Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading a YAML file which contains a date fails #362

Closed
tanner-bruce opened this issue Jun 7, 2018 · 2 comments
Closed

Loading a YAML file which contains a date fails #362

tanner-bruce opened this issue Jun 7, 2018 · 2 comments

Comments

@tanner-bruce
Copy link

Simplest way to reproduce:
YAML.safe_load('expiry: 2018-02-08 03:32:36')

results in

Traceback (most recent call last):
       16: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/visitor.rb:6:in `accept'
       15: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/visitor.rb:16:in `visit'
       14: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/to_ruby.rb:162:in `visit_Psych_Nodes_Mapping'
       13: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/to_ruby.rb:336:in `revive_hash'
       12: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/to_ruby.rb:336:in `each_slice'
       11: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/to_ruby.rb:336:in `each'
       10: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/to_ruby.rb:338:in `block in revive_hash'
        9: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/to_ruby.rb:32:in `accept'
        8: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/visitor.rb:6:in `accept'
        7: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/visitor.rb:16:in `visit'
        6: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/to_ruby.rb:123:in `visit_Psych_Nodes_Scalar'
        5: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/visitors/to_ruby.rb:60:in `deserialize'
        4: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/scalar_scanner.rb:62:in `tokenize'
        3: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/scalar_scanner.rb:123:in `parse_time'
        2: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/class_loader.rb:28:in `load'
        1: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/psych/class_loader.rb:97:in `find'
Psych::DisallowedClass (Tried to load unspecified class: Time)
@cben
Copy link

cben commented Jun 7, 2018

Seems this is not a bug, it's the documented default.
Psych.safe_load('expiry: 2018-02-08 03:32:36', [Date, Time]) works.

[P.S. for future readers finding this: see also #262 for explanation how some date-like inputs do get parsed, as strings — if they're not valid dates]

@tanner-bruce
Copy link
Author

Thanks @cben!

sunaku added a commit to sunaku/readably that referenced this issue Oct 7, 2022
  $ bundle exec rake
  Psych::DisallowedClass: Could not load blog entry file "content/*.readably"
  Tried to load unspecified class: Time

See also ruby/psych#362
sunaku added a commit to sunaku/readably that referenced this issue Oct 24, 2023
  $ bundle exec rake
  Psych::DisallowedClass: Could not load blog entry file "content/*.readably"
  Tried to load unspecified class: Time

See also ruby/psych#362
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants