Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

I18n exception when error contains two dots

#3786

I don't use I18n in this project but it generated an exception in my code because two dots (..) happened to be in an error message, see this code:

def validate
   name="test..test"
   errors.add(:name,"cannot be #{name}")
end

@person.save!
# =>  interning empty string
 /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb:196:in `to_sym'

This happens in the code that generates the error message for the exception, so @person.save will work, but @person.save! will not. This can trip up people who use user generated text in their error messages.

Reported by Fjan · January 25th, 2010 @ 10:55 AM

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from new to invalid

    Thank you for sending bug report.

    I have talked to the writer of i18n, and looks like it has been fixed in i18n version 0.3.3. Please install it by running gem install i18n, or wait for 2.3.6 which will bundled with 0.3.3 already.

    However, I encourage you to install the i18n gem. Rails will try to look for installed gem first, before using the outdated version which was vendored.

    January 27th, 2010 @ 05:14 PM

  2. Fjan
    Fjan

    Ok, thanks. By the way, if I18n calls to_sym on my dynamically generated error messages that would probably constitute a memory leak. I guess I'll have to go bug them about it.

    January 27th, 2010 @ 05:34 PM