diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-12-04 16:25:50 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-12-04 22:34:15 -0200 |
commit | 31a485fa5a843a766c4b889ee88a6c590a3a6ebb (patch) | |
tree | 8450bb26acbe29d281de997bdbdb4721832530ea /actionpack/lib/action_view/helpers/translation_helper.rb | |
parent | c82025fcd6f5da92448a1362b38c0a0a9e966a12 (diff) | |
download | rails-31a485fa5a843a766c4b889ee88a6c590a3a6ebb.tar.gz rails-31a485fa5a843a766c4b889ee88a6c590a3a6ebb.tar.bz2 rails-31a485fa5a843a766c4b889ee88a6c590a3a6ebb.zip |
Merge pull request #13183 from sorah/never_ignore_i18n_translate_raise_option
Escalate missing error when :raise is true in translate helper, fix regression introduced by security fix.
Conflicts:
actionpack/CHANGELOG.md
Diffstat (limited to 'actionpack/lib/action_view/helpers/translation_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/translation_helper.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb index 6ef652d328..4654a6fa1f 100644 --- a/actionpack/lib/action_view/helpers/translation_helper.rb +++ b/actionpack/lib/action_view/helpers/translation_helper.rb @@ -36,7 +36,13 @@ module ActionView def translate(key, options = {}) # If the user has specified rescue_format then pass it all through, otherwise use # raise and do the work ourselves - options[:raise] = true unless options.key?(:raise) || options.key?(:rescue_format) + if options.key?(:raise) || options.key?(:rescue_format) + raise_error = options[:raise] || options[:rescue_format] + else + raise_error = false + options[:raise] = true + end + if html_safe_translation_key?(key) html_safe_options = options.dup options.except(*I18n::RESERVED_KEYS).each do |name, value| @@ -51,6 +57,8 @@ module ActionView I18n.translate(scope_key_by_partial(key), options) end rescue I18n::MissingTranslationData => e + raise e if raise_error + keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope]) content_tag('span', keys.last.to_s.titleize, :class => 'translation_missing', :title => "translation missing: #{keys.join('.')}") end |