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

Use safe_load when using Psych >=3.1 #34

Merged
merged 2 commits into from Jun 7, 2021
Merged

Use safe_load when using Psych >=3.1 #34

merged 2 commits into from Jun 7, 2021

Conversation

knu
Copy link
Member

@knu knu commented Jun 7, 2021

I don't think there are use cases where an untrusted YAML jar should be loaded, but it is a good practice to be explicit about which classes are expected to be serialized in the YAML jar format.

Because CI for 1.8.7/REE was broken, I ran the test suite manually in my local environment with ruby 1.8.7.

This fixes #33.


if YAML.name == 'Psych' && Psych::VERSION >= '3.1'
def load_yaml(yaml)
YAML.safe_load(yaml, :permitted_classes => %w[Time HTTP::Cookie Mechanize::Cookie])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

psych >=3.1 supports keyword arguments. We still support ruby 1.8.7, hence the rocket syntax.

@@ -73,4 +73,14 @@ def load(io, jar)
def default_options
{}
end

if YAML.name == 'Psych' && Psych::VERSION >= '3.1'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"3.10" > "3.1", in case you wonder.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am so very late here (thanks for doing this update btw), but in the distant future "10.0" < "3.1" :)

@knu
Copy link
Member Author

knu commented Jun 7, 2021

Just pushed v1.0.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants