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

Support psych 4 #4

Merged
merged 2 commits into from
Oct 20, 2023
Merged

Support psych 4 #4

merged 2 commits into from
Oct 20, 2023

Conversation

playerace
Copy link

@playerace playerace commented Oct 20, 2023

Bacgkground

With TE upgrading to ruby 3.1.4 (internally using Psych 4), we can follow the rails team loading of YAML.safe_load.
We also now have the option of removing safe_yaml gem in TE.

Comment on lines +49 to +55
if ActiveRecord::Base.use_yaml_unsafe_load
YAML.unsafe_load(yaml)
elsif YAML.method(:safe_load).parameters.include?([:key, :permitted_classes])
YAML.safe_load(yaml, permitted_classes: ActiveRecord::Base.yaml_column_permitted_classes, aliases: true)
else
YAML.safe_load(yaml, ActiveRecord::Base.yaml_column_permitted_classes, [], true)
end
Copy link
Author

Choose a reason for hiding this comment

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

This will not affect TE master on 3.0.4 because we still use SafeYAML and this part of the change will only be used once the SafeYAML gem is removed.

The else at line 53 will also handle Psych 3.3.2 when it was still using positional arguments instead of keyword arguments. ruby/psych@v3.3.2...v4.0.0#diff-659eac8589abc82c9a0ab3699e4e4be4774d9c09c6c9934af5d9dae0d264439cL330

@playerace playerace merged commit dafa0d9 into master Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants