Skip to content

Make SafeYAML.load an alias of safe_load#9391

Merged
hsbt merged 5 commits intoruby:masterfrom
jhawthorn:fix_safe_yaml_load
Mar 12, 2026
Merged

Make SafeYAML.load an alias of safe_load#9391
hsbt merged 5 commits intoruby:masterfrom
jhawthorn:fix_safe_yaml_load

Conversation

@jhawthorn
Copy link
Member

In #9352, when using Psych, SafeYAML.load was changed to Psych.unsafe_load, which we should not be using at all.

Looking into this a little more, I don't think we need a SafeYAML.load. It was already safe (more restrictive than safe_load, other than maybe allowing more symbols?). The only user we had was owner_command, which probably should have been using safe_load.

I made this in separate commits, so feel free to cherry-pick or squash if not all of this is desirable. Only the first is essential to remove unsafe_load, the rest is cleanup.

cc @hsbt

This was changed to unsafe_load with the swap to YAMLSerializer. But
this method did not previously do an unsafe load and we shouldn't
provide that.
This had been the only user of Gem::SafeYAML.load for a long time. We
might as well be consistent with all other uses and use safe_load.
Using Psych, load was actually more restrictive than safe_load. Using
Gem::YAMLSerializer they were identical. We might as well use the same
path for both methods.
@jhawthorn jhawthorn force-pushed the fix_safe_yaml_load branch from a2074cd to d8d927f Compare March 12, 2026 02:55
Copy link
Member

@hsbt hsbt left a comment

Choose a reason for hiding this comment

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

Thanks! That maked sense to me. We should introduce safe_load only.

@hsbt hsbt enabled auto-merge March 12, 2026 03:37
@hsbt hsbt merged commit cc86612 into ruby:master Mar 12, 2026
130 of 136 checks passed
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.

2 participants