-
Notifications
You must be signed in to change notification settings - Fork 16
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
Permit Time
class loading from YAML.
#81
Conversation
Since Psych 4.0, the `safe_load` is used as default loading mechanism. There are just a few permitted classes and `Time` is not one of them [[1]]. This results it test failure: ~~~ Error: test_converting_to_yaml(DocumentTest::TestSimpleConventionallyNamedDocument): Psych::DisallowedClass: Tried to load unspecified class: Time ~~~ Please also note that in YAML specs 1.2, the `timestamp` is not listed as supported tag anymore [[2]]. Given that: 1) ronn-ng does not provide any supported way of loading the serialized YAML. 2) The `to_yaml` does not appear to be used internally/externally anywhere. 3) If there were users of this functionality, it would have been already know, reported and fixed at this moment. The best course of action is fixing the test case by listing the `Time` as valid class for parsing. Fixes apjanke#80 [1]: https://docs.ruby-lang.org/en/master/Psych.html#method-c-safe_load [2]: yaml/yaml-spec#268
4bc23da
to
25158fa
Compare
Ok, now how to make this compatible with old Rubies 🤔 |
This is due to Ruby 3.1 + Psych 4.0 changed changed `YAML.load` to use `safe_load` by default.
16a5bdb
to
78249ea
Compare
This is to make the test case less poluted. Can be dropped once only Ruby 3.1+ is supported.
This should make Rubocop happy.
78249ea
to
7c49ae1
Compare
Ok, so finally, the test suite is passing on CI for Ruby 2.7. The older Rubies fails due to some issues installing Nokogiri. The test matrix would certainly deserve some refresh. The PR ATM consists of 4 commits as the PR evolved. They could be squashed. Or the patch with extracted |
Fixed in e194bf6, I think. |
Since Psych 4.0, the
safe_load
is used as default loading mechanism. There are just a few permitted classes andTime
is not one of them [1]. This results it test failure:Please also note that in YAML specs 1.2, the
timestamp
is not listed as supported tag anymore [2].Given that:
to_yaml
does not appear to be used internally/externally anywhere.The best course of action is fixing the test case by listing the
Time
as valid class for parsing.Fixes #80