This project is archived and is in readonly mode.

#4942 ✓resolved
Leigh Caplan

ActiveSupport::TimeZone.[] incorrectly stores bogus values in zones_map

Reported by Leigh Caplan | June 23rd, 2010 @ 03:39 AM | in 2.3.9

>> ActiveSupport::TimeZone['bogus']
=> nil
>> ActiveSupport::TimeZone.zones_map.key?('bogus')
=> true

This really bites you if the value ends up being stored, but ActiveSupport::TimeZone.all hasn't been called yet. In this case, ActiveSupport::TimeZone.zones_map.values gets sorted, and blows up because nil has no <=> defined.

This was never an issue before 49943a712080644969d1, because ZONES and US_ZONES were pre-loaded before any shenanigans of this sort could take place.

I've included a patch that should apply to both 2-3-stable and master. Note that this failure mode doesn't rear its head in master, as long as you're using a newer version of the tzinfo gem- trying to look up a nonexistent time zone will raise an error. That being said, if the tzinfo behavior changed tomrrow, Rails would again be vulnerable due to the way this code is written.

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=""></a>