This project is archived and is in readonly mode.

#3447 ✓resolved
Vlad R

i18n-0.1.3 fails with 'interning empty string' in i18n.rb:196

Reported by Vlad R | November 1st, 2009 @ 06:26 AM

i18n-0.1.3 fails with...

  interning empty string
  [RAILS_ROOT]/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb:196:in `to_sym'

...in i18n.rb:196 when calling model.errors[:field] after having called model.errors.add(:field, 'custom message with two or more consecutive periods .. in the middle')

This is because split(/\./) with return at least one empty string when two or more consecutive periods appear in the middle or at the beginning of the string to be split.

      keys = [locale] + Array(scope) + [key]
      keys = keys.map { |k| k.to_s.split(/\./) }
      keys.flatten.map { |k| k.to_sym }

should probably be changed to something like:

      keys = [locale] + Array(scope) + [key]
      keys = keys.map { |k| k.to_s.split(/\./) }
      keys.flatten.reject(&:empty?).map { |k| k.to_sym }

...or change the regexp to /\.+/ etc.

Cheers,
V.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages