From 25158fabc2c83862de90f319b7dffc9e60904dac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Tue, 30 Aug 2022 09:07:15 +0200 Subject: [PATCH] Permit `Time` class loading from YAML. 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 #80 [1]: https://docs.ruby-lang.org/en/master/Psych.html#method-c-safe_load [2]: https://github.com/yaml/yaml-spec/issues/268 --- test/test_ronn_document.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_ronn_document.rb b/test/test_ronn_document.rb index 75788dc..a86793f 100644 --- a/test/test_ronn_document.rb +++ b/test/test_ronn_document.rb @@ -146,7 +146,7 @@ def canonicalize(text) 'toc' => [['NAME', 'NAME']], 'organization' => nil, 'manual' => nil - }, YAML.load(@doc.to_yaml)) + }, YAML.load(@doc.to_yaml, permitted_classes: [Time])) end test 'converting to json' do