File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed
lib/active_support/values Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1+ * Fix ` ActiveSupport::TimeZone#strptime ` . Now raises ` ArgumentError ` when the
2+ given time doesn't match the format. The error is the same as the one given
3+ by Ruby's ` Date.strptime ` . Previously it raised
4+ ` NoMethodError: undefined method empty? for nil:NilClass. ` due to a bug.
5+
6+ Fixes #25701 .
7+
8+ * John Gesimondo*
9+
10+
111## Rails 5.0.0 (June 30, 2016) ##
212
313* Support parsing JSON time in ISO8601 local time strings in
Original file line number Diff line number Diff line change @@ -447,6 +447,7 @@ def encode_with(coder) #:nodoc:
447447
448448 private
449449 def parts_to_time ( parts , now )
450+ raise ArgumentError , "invalid date" if parts . nil?
450451 return if parts . empty?
451452
452453 time = Time . new (
Original file line number Diff line number Diff line change @@ -388,6 +388,13 @@ def test_strptime_with_day_omitted
388388 end
389389 end
390390
391+ def test_strptime_with_malformed_string
392+ with_env_tz 'US/Eastern' do
393+ zone = ActiveSupport ::TimeZone [ 'Eastern Time (US & Canada)' ]
394+ assert_raise ( ArgumentError ) { zone . strptime ( '1999-12-31' , '%Y/%m/%d' ) }
395+ end
396+ end
397+
391398 def test_utc_offset_lazy_loaded_from_tzinfo_when_not_passed_in_to_initialize
392399 tzinfo = TZInfo ::Timezone . get ( 'America/New_York' )
393400 zone = ActiveSupport ::TimeZone . create ( tzinfo . name , nil , tzinfo )
You can’t perform that action at this time.
0 commit comments