Skip to content

Instantly share code, notes, and snippets.

@hassox
Created June 22, 2012 22:14
Show Gist options
  • Select an option

  • Save hassox/2975498 to your computer and use it in GitHub Desktop.

Select an option

Save hassox/2975498 to your computer and use it in GitHub Desktop.
# Protect your locales yo! don't specify directly from user input
## Rails 2.3 ree 1.8.7
>> Symbol.all_symbols.any?{ |s| s.to_s == "weird string" }
=> false
>> I18n.locale = "weird string"
=> "weird string"
>> Symbol.all_symbols.any?{ |s| s.to_s == "weird string" }
=> true
## Rails 3.2
1.9.3-p194-perf :001 > Symbol.all_symbols.any?{ |s| s.to_s == "weird string" }
=> false
1.9.3-p194-perf :002 > I18n.locale = "weird string"
=> "weird string"
1.9.3-p194-perf :003 > Symbol.all_symbols.any?{ |s| s.to_s == "weird string" }
=> true
1.9.3-p194-perf :004 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment