Skip to content

Use YAML.unsafe_load to load configuration file #1217

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

Merged
merged 1 commit into from
Feb 5, 2022
Merged

Conversation

aepyornis
Copy link
Contributor

Ruby 3.1 comes with Psych 4 which has some breaking changes to YAML.load See this ruby issue.

I had been using a config/thinking_sphinx.yml file with aliases, which failed to load after I upgraded a rails app to ruby 3.1. Here's an example configuration:

defaults: &defaults
  min_word_len: 2
  charset_table: "0..9, A..Z->a..z, _, a..z, \
  U+410..U+42F->U+430..U+44F, U+430..U+44F"

test:
  <<: *defaults
  mysql41: 9313

development:
  <<: *defaults

production:
  <<: *defaults
  address: 10.0.0.1

Such a configuration works with ruby versions prior to 3.1.

@pat pat merged commit a5dbbd4 into pat:develop Feb 5, 2022
@pat
Copy link
Owner

pat commented Feb 5, 2022

Thanks, I'll merge this in - but also, wondering if we can use safe loading with aliases explicitly allowed?

@pat
Copy link
Owner

pat commented Feb 5, 2022

To keep backwards compatibility for older Psych/Ruby versions, I've tweaked this to use safe_load with aliases in newer versions, and load for the older approach.

@aepyornis
Copy link
Contributor Author

thanks so much!

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