This project is archived and is in readonly mode.

#3786 ✓invalid
Fjan

I18n exception when error contains two dots

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

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.

Comments and changes to this ticket

  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) January 27th, 2010 @ 05:14 PM

    • 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.

  • Fjan

    Fjan January 27th, 2010 @ 05:34 PM

    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.

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>

People watching this ticket

Tags

Pages