pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 469 forks source link

Use YAML.unsafe_load to load configuration file #1217

Closed aepyornis closed 2 years ago

aepyornis commented 2 years ago

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 commented 2 years ago

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

pat commented 2 years ago

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 commented 2 years ago

thanks so much!