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

hash.slice will crash if keep_key is not in the original hash #291

Closed
brettcave opened this issue Oct 1, 2014 · 2 comments
Closed

hash.slice will crash if keep_key is not in the original hash #291

brettcave opened this issue Oct 1, 2014 · 2 comments

Comments

@brettcave
Copy link

lib/i18n/core_ext/hash.rb#L4 will crash if :some_key is in keep_keys but not in the hash.

A safe way to allow keep_keys to be passed to the slice function that are not in the hash is to add a if has_key?(key):

keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
brettcave added a commit to brettcave/i18n that referenced this issue Oct 1, 2014
brettcave added a commit to brettcave/i18n that referenced this issue Oct 1, 2014
brettcave added a commit to brettcave/i18n that referenced this issue Oct 1, 2014
brettcave added a commit to brettcave/i18n that referenced this issue Oct 1, 2014
@codegoalie
Copy link

I believe this was fixed with #289 and can be closed.

@carlosantoniodasilva
Copy link
Member

Thanks.

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

No branches or pull requests

3 participants