tzinfo 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of tzinfo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff316f9ef3e063d02096d2d1841b832491e315d78610d8751b09115632794e9f
4
- data.tar.gz: b695fca6cdc7af5cd356dbb592aacc81c861d64e05375a5c6238c9ae924fe8be
3
+ metadata.gz: c204b46efe2fc4448fbb719bc143c031e71e5a5eaa21593cee6b04a8904b21f6
4
+ data.tar.gz: a70e08a0cb1ed9439ca48899e068e0455d2bf123601ef19db308cd9a39e156ba
5
5
  SHA512:
6
- metadata.gz: 6ab8e7340dd1eafa73c385e388d49c2bf07203e855b3410c6302abc9b5e5b9992f1cfdb9aa5dc5dc59664f713618e25eac7489b7be5209a5987162e90cfe48d9
7
- data.tar.gz: 5db4b130ed3db4b07d350b6acb020781d6538c9f9295d478b297fe994c2ac4220dbd76097ed2c5a26219cdf6ec10bb18df6816f904cdd0c5ac1193782730785c
6
+ metadata.gz: 15ec7aefd75724e350d8f287d2b9af340af7e5916f6e535dd1d6673bbdeae2615992dd5b33181a354b400bce39fb054fd691d41453b335f5a527847eecfaf2b4
7
+ data.tar.gz: 6766a63a1a690944ef8ea3ac1ed9d5018216d1f139a1bbcddf99f00fa293bf56779b71bf2e27c80e0d4bf01cdcba375b3f6b5d046470324713a43e0747e0a9dd
@@ -1,3 +1,2 @@
1
- 0뱱�M��f\]�!�5� l|��>���P��Cy
2
- ���:��42d��Y.fbRv��}8�.�w.�0D��A&7`5`�&�.�z,}���"OOn^��\��Փ�t�J-{����5�1���i�\�G���C�Q���GX2
3
- �Ck=�t�1�X�{L���z��� @�K�;v�Mz�s�n=/m�I�ZF��;ݍƁu*�-6�Rքt��G�KV�?����C
1
+ ���Ш{���!1��Q���p� ����R|�C wN�#�|Q�/T�.�4�i�h���a�f�O�@�GhF}�]ֱ�YL@܅��OGu%6h�k�1,gᔈ�^J�VR�h��?T���5��Cj������Md���_zI�o0}�π�-��
2
+ D~Km�~L5٥_.����|�˪o%\�TВ��=�ҹ�����l3 ƴ��X]6��y��R��DX47i�VMfvH��ݦ[L��7Om{Be��m
data.tar.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,14 @@
1
+ Version 1.2.6 - 24-Dec-2019
2
+ ---------------------------
3
+
4
+ * Timezone#strftime('%s', time) will now return the correct number of seconds
5
+ since the epoch. #91.
6
+ * Removed the unused TZInfo::RubyDataSource::REQUIRE_PATH constant.
7
+ * Fixed "SecurityError: Insecure operation - require" exceptions when loading
8
+ data with recent Ruby releases in safe mode.
9
+ * Fixed warnings when running on Ruby 2.7. #106 and #111.
10
+
11
+
1
12
  Version 1.2.5 - 4-Feb-2018
2
13
  --------------------------
3
14
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005-2018 Philip Ross
1
+ Copyright (c) 2005-2019 Philip Ross
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -60,8 +60,9 @@ of `TZInfo::Timezone`) and convert a time in UTC to local New York time:
60
60
  local = tz.utc_to_local(Time.utc(2005,8,29,15,35,0))
61
61
 
62
62
  Note that the local Time returned will have a UTC timezone (`local.zone` will
63
- return `"UTC"`). This is because the Ruby Time class only supports two timezones:
64
- UTC and the current system local timezone.
63
+ return `"UTC"`). This is because the Time class in older (but still supported by
64
+ TZInfo) versions of Ruby can only handle two timezones: UTC and the system local
65
+ timezone.
65
66
 
66
67
  To convert from a local time to UTC, the `local_to_utc` method can be used as
67
68
  follows:
@@ -137,10 +137,40 @@ module TZInfo
137
137
  def self.open_file(file_name, mode, opts, &block)
138
138
  File.open(file_name, mode, &block)
139
139
  end
140
- else
140
+ elsif RUBY_VERSION =~ /\A1\.9\./
141
141
  def self.open_file(file_name, mode, opts, &block)
142
142
  File.open(file_name, mode, opts, &block)
143
143
  end
144
+ else
145
+ # Evaluate method as a string because **opts isn't valid syntax prior to
146
+ # Ruby 2.0.
147
+ eval(<<-EOF
148
+ def self.open_file(file_name, mode, opts, &block)
149
+ File.open(file_name, mode, **opts, &block)
150
+ end
151
+ EOF
152
+ )
153
+ end
154
+
155
+
156
+ # Object#untaint is a deprecated no-op in Ruby >= 2.7 and will be removed in
157
+ # 3.0. Add a refinement to either silence the warning, or supply the method
158
+ # if needed.
159
+ old_verbose = $VERBOSE
160
+ $VERBOSE = false
161
+ begin
162
+ o = Object.new
163
+ if [:taint, :untaint, :tainted?].none? {|m| o.respond_to?(m) } || !o.taint.tainted?
164
+ module UntaintExt
165
+ refine Object do
166
+ def untaint
167
+ self
168
+ end
169
+ end
170
+ end
171
+ end
172
+ ensure
173
+ $VERBOSE = old_verbose
144
174
  end
145
175
  end
146
176
  end
@@ -1,4 +1,6 @@
1
1
  module TZInfo
2
+ using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
3
+
2
4
  # A DataSource that loads data from the set of Ruby modules included in the
3
5
  # TZInfo::Data library (tzinfo-data gem).
4
6
  #
@@ -6,15 +8,30 @@ module TZInfo
6
8
  #
7
9
  # TZInfo::DataSource.set(:ruby)
8
10
  class RubyDataSource < DataSource
9
- # Base path for require.
10
- REQUIRE_PATH = File.join('tzinfo', 'data', 'definitions')
11
-
12
11
  # Whether the timezone index has been loaded yet.
13
12
  @@timezone_index_loaded = false
14
13
 
15
14
  # Whether the country index has been loaded yet.
16
15
  @@country_index_loaded = false
17
16
 
17
+ # Initializes a new RubyDataSource instance.
18
+ def initialize
19
+ tzinfo_data = File.join('tzinfo', 'data')
20
+ begin
21
+ require(tzinfo_data)
22
+
23
+ data_file = File.join('', 'tzinfo', 'data.rb')
24
+ path = $".reverse_each.detect {|p| p.end_with?(data_file) }
25
+ if path
26
+ @base_path = File.join(File.dirname(path), 'data').untaint
27
+ else
28
+ @base_path = tzinfo_data
29
+ end
30
+ rescue LoadError
31
+ @base_path = tzinfo_data
32
+ end
33
+ end
34
+
18
35
  # Returns a TimezoneInfo instance for a given identifier.
19
36
  # Raises InvalidTimezoneIdentifier if the timezone is not found or the
20
37
  # identifier is invalid.
@@ -93,27 +110,17 @@ module TZInfo
93
110
  end
94
111
 
95
112
  # Requires an index by its name.
96
- def self.require_index(name)
113
+ def require_index(name)
97
114
  require_data(*['indexes', name])
98
115
  end
99
116
 
100
117
  # Requires a file from tzinfo/data.
101
118
  def require_data(*file)
102
- self.class.require_data(*file)
103
- end
104
-
105
- # Requires a file from tzinfo/data.
106
- def self.require_data(*file)
107
- require File.join('tzinfo', 'data', *file)
119
+ require(File.join(@base_path, *file))
108
120
  end
109
121
 
110
122
  # Loads in the index of timezones if it hasn't already been loaded.
111
123
  def load_timezone_index
112
- self.class.load_timezone_index
113
- end
114
-
115
- # Loads in the index of timezones if it hasn't already been loaded.
116
- def self.load_timezone_index
117
124
  unless @@timezone_index_loaded
118
125
  require_index('timezones')
119
126
  @@timezone_index_loaded = true
@@ -122,11 +129,6 @@ module TZInfo
122
129
 
123
130
  # Loads in the index of countries if it hasn't already been loaded.
124
131
  def load_country_index
125
- self.class.load_country_index
126
- end
127
-
128
- # Loads in the index of countries if it hasn't already been loaded.
129
- def self.load_country_index
130
132
  unless @@country_index_loaded
131
133
  require_index('countries')
132
134
  @@country_index_loaded = true
@@ -571,17 +571,21 @@ module TZInfo
571
571
  # version 2.0.0, %z will be passed to Time#strftime and DateTime#strftime
572
572
  # instead. Some of the formatting options may cease to be available
573
573
  # depending on the version of Ruby in use (for example, %:::z is only
574
- # supported by Time#strftime from MRI version 2.0.0 onwards.)
574
+ # supported by Time#strftime from MRI version 2.0.0 onwards).
575
575
  def strftime(format, utc = Time.now.utc)
576
+ utc = TimeOrDateTime.wrap(utc)
576
577
  period = period_for_utc(utc)
577
- local = period.to_local(utc)
578
- local = Time.at(local).utc unless local.kind_of?(Time) || local.kind_of?(DateTime)
578
+ local_wrapped = period.to_local(utc)
579
+ local = local_wrapped.to_orig
580
+ local = local_wrapped.to_time unless local.kind_of?(Time) || local.kind_of?(DateTime)
579
581
  abbreviation = period.abbreviation.to_s.gsub(/%/, '%%')
580
582
 
581
- format = format.gsub(/%(%*)(Z|:*z)/) do
583
+ format = format.gsub(/%(%*)([sZ]|:*z)/) do
582
584
  if $1.length.odd?
583
585
  # Escaped literal percent or series of percents. Pass on to strftime.
584
586
  "#$1%#$2"
587
+ elsif $2 == "s"
588
+ "#$1#{utc.to_i}"
585
589
  elsif $2 == "Z"
586
590
  "#$1#{abbreviation}"
587
591
  else
@@ -1,4 +1,12 @@
1
1
  module TZInfo
2
+ # Use send as a workaround for an issue on JRuby 9.2.9.0 where using the
3
+ # refinement causes calls to RubyCoreSupport.file_open to fail to pass the
4
+ # block parameter.
5
+ #
6
+ # https://travis-ci.org/tzinfo/tzinfo/jobs/628812051#L1931
7
+ # https://github.com/jruby/jruby/issues/6009
8
+ send(:using, TZInfo::RubyCoreSupport::UntaintExt) if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)
9
+
2
10
  # An InvalidZoneinfoDirectory exception is raised if the DataSource is
3
11
  # set to a specific zoneinfo path, which is not a valid zoneinfo directory
4
12
  # (i.e. a directory containing index files named iso3166.tab and zone.tab
@@ -1,4 +1,6 @@
1
1
  module TZInfo
2
+ using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
3
+
2
4
  # An InvalidZoneinfoFile exception is raised if an attempt is made to load an
3
5
  # invalid zoneinfo file.
4
6
  class InvalidZoneinfoFile < StandardError
@@ -2,6 +2,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
2
2
 
3
3
  include TZInfo
4
4
 
5
+ using TaintExt if Module.const_defined?(:TaintExt)
6
+
5
7
  class TCCountry < Minitest::Test
6
8
  def setup
7
9
  @orig_data_source = DataSource.get
@@ -46,7 +48,7 @@ class TCCountry < Minitest::Test
46
48
  def test_get_tainted_loaded
47
49
  Country.get('GB')
48
50
 
49
- safe_test do
51
+ safe_test(:unavailable => :skip) do
50
52
  code = 'GB'.dup.taint
51
53
  assert(code.tainted?)
52
54
  country = Country.get(code)
@@ -65,7 +67,7 @@ class TCCountry < Minitest::Test
65
67
  end
66
68
 
67
69
  def test_get_tainted_not_previously_loaded
68
- safe_test do
70
+ safe_test(:unavailable => :skip) do
69
71
  code = 'GB'.dup.taint
70
72
  assert(code.tainted?)
71
73
  country = Country.get(code)
@@ -2,11 +2,29 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
2
2
 
3
3
  include TZInfo
4
4
 
5
+ using TaintExt if Module.const_defined?(:TaintExt)
6
+
5
7
  class TCRubyDataSource < Minitest::Test
6
8
  def setup
7
9
  @data_source = RubyDataSource.new
8
10
  end
9
11
 
12
+ def test_initialize_not_found
13
+ # A failure to load tzinfo/data in initialize will not cause an exception.
14
+ # Attempts to load data files will subsequently fail.
15
+ code = <<-EOF
16
+ begin
17
+ ds = TZInfo::RubyDataSource.new
18
+ puts 'Initialized'
19
+ ds.load_timezone_info('Europe/London')
20
+ rescue Exception => e
21
+ puts e.class
22
+ end
23
+ EOF
24
+
25
+ assert_sub_process_returns(['Initialized', 'TZInfo::InvalidTimezoneIdentifier'], code)
26
+ end
27
+
10
28
  def test_load_timezone_info_data
11
29
  info = @data_source.load_timezone_info('Europe/London')
12
30
  assert_kind_of(DataTimezoneInfo, info)
@@ -55,7 +73,9 @@ class TCRubyDataSource < Minitest::Test
55
73
  end
56
74
 
57
75
  def test_load_timezone_info_tainted
58
- safe_test do
76
+ skip_if_has_bug_14060
77
+
78
+ safe_test(:unavailable => :skip) do
59
79
  identifier = 'Europe/Amsterdam'.dup.taint
60
80
  assert(identifier.tainted?)
61
81
  info = @data_source.load_timezone_info(identifier)
@@ -65,6 +85,8 @@ class TCRubyDataSource < Minitest::Test
65
85
  end
66
86
 
67
87
  def test_load_timezone_info_tainted_and_frozen
88
+ skip_if_has_bug_14060
89
+
68
90
  safe_test do
69
91
  info = @data_source.load_timezone_info('Europe/Amsterdam'.dup.taint.freeze)
70
92
  assert_equal('Europe/Amsterdam', info.identifier)
@@ -119,7 +141,7 @@ class TCRubyDataSource < Minitest::Test
119
141
  end
120
142
 
121
143
  def test_load_country_info_tainted
122
- safe_test do
144
+ safe_test(:unavailable => :skip) do
123
145
  code = 'NL'.dup.taint
124
146
  assert(code.tainted?)
125
147
  info = @data_source.load_country_info(code)
@@ -4,6 +4,12 @@ require 'rational' unless defined?(Rational)
4
4
  include TZInfo
5
5
 
6
6
  class TCTimeOrDateTime < Minitest::Test
7
+ # Ruby 1.8.7 (built with GCC 8.3.0 on Ubuntu 19.04) fails to perform DateTime
8
+ # arithmetic operations correctly when sub-seconds are used. Detect this and
9
+ # disable the affected tests.
10
+ DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN = (DateTime.new(2019, 12, 22, 15, 0, Rational(1, 1000)) + Rational(1, 86400)).strftime('%Q') != '1577026801001'
11
+ puts "DateTime sub-second arithmetic is broken on this platform" if DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
12
+
7
13
  def test_initialize_time
8
14
  assert_nothing_raised do
9
15
  TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000))
@@ -500,12 +506,12 @@ class TCTimeOrDateTime < Minitest::Test
500
506
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) + 1).to_orig)
501
507
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) + 1).to_orig)
502
508
  assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) + 1).to_orig)
503
- assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + 1).to_orig)
509
+ assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + 1).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
504
510
  assert_equal(1143214324, (TimeOrDateTime.new(1143214323) + 1).to_orig)
505
511
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) + (-1)).to_orig)
506
512
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) + (-1)).to_orig)
507
513
  assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) + (-1)).to_orig)
508
- assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + (-1)).to_orig)
514
+ assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + (-1)).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
509
515
  assert_equal(1143214322, (TimeOrDateTime.new(1143214323) + (-1)).to_orig)
510
516
  end
511
517
 
@@ -518,12 +524,12 @@ class TCTimeOrDateTime < Minitest::Test
518
524
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) - 1).to_orig)
519
525
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) - 1).to_orig)
520
526
  assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) - 1).to_orig)
521
- assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - 1).to_orig)
527
+ assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - 1).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
522
528
  assert_equal(1143214322, (TimeOrDateTime.new(1143214323) - 1).to_orig)
523
529
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) - (-1)).to_orig)
524
530
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) - (-1)).to_orig)
525
531
  assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) - (-1)).to_orig)
526
- assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - (-1)).to_orig)
532
+ assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - (-1)).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
527
533
  assert_equal(1143214324, (TimeOrDateTime.new(1143214323) - (-1)).to_orig)
528
534
  end
529
535
 
@@ -536,12 +542,12 @@ class TCTimeOrDateTime < Minitest::Test
536
542
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).add_with_convert(1).to_orig)
537
543
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).add_with_convert(1).to_orig)
538
544
  assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).add_with_convert(1).to_orig)
539
- assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(1).to_orig)
545
+ assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(1).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
540
546
  assert_equal(1143214324, TimeOrDateTime.new(1143214323).add_with_convert(1).to_orig)
541
547
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).add_with_convert(-1).to_orig)
542
548
  assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).add_with_convert(-1).to_orig)
543
549
  assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).add_with_convert(-1).to_orig)
544
- assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(-1).to_orig)
550
+ assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(-1).to_orig) unless DATETIME_SUBSECOND_ARITHMETIC_IS_BROKEN
545
551
  assert_equal(1143214322, TimeOrDateTime.new(1143214323).add_with_convert(-1).to_orig)
546
552
 
547
553
  if RubyCoreSupport.time_supports_negative
@@ -2,6 +2,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
2
2
 
3
3
  include TZInfo
4
4
 
5
+ using TaintExt if Module.const_defined?(:TaintExt)
6
+
5
7
  class TCTimezone < Minitest::Test
6
8
 
7
9
  class BlockCalled < StandardError
@@ -242,7 +244,7 @@ class TCTimezone < Minitest::Test
242
244
  def test_get_tainted_loaded
243
245
  Timezone.get('Europe/Andorra')
244
246
 
245
- safe_test do
247
+ safe_test(:unavailable => :skip) do
246
248
  identifier = 'Europe/Andorra'.dup.taint
247
249
  assert(identifier.tainted?)
248
250
  tz = Timezone.get(identifier)
@@ -261,7 +263,9 @@ class TCTimezone < Minitest::Test
261
263
  end
262
264
 
263
265
  def test_get_tainted_not_previously_loaded
264
- safe_test do
266
+ skip_if_has_bug_14060
267
+
268
+ safe_test(:unavailable => :skip) do
265
269
  identifier = 'Europe/Andorra'.dup.taint
266
270
  assert(identifier.tainted?)
267
271
  tz = Timezone.get(identifier)
@@ -271,6 +275,8 @@ class TCTimezone < Minitest::Test
271
275
  end
272
276
 
273
277
  def test_get_tainted_and_frozen_not_previously_loaded
278
+ skip_if_has_bug_14060
279
+
274
280
  safe_test do
275
281
  tz = Timezone.get('Europe/Amsterdam'.dup.taint.freeze)
276
282
  assert_equal('Europe/Amsterdam', tz.identifier)
@@ -1260,6 +1266,7 @@ class TCTimezone < Minitest::Test
1260
1266
  assert_equal('BST BST', tz.strftime('%Z %Z', dt))
1261
1267
  assert_equal('BST %Z %BST %%Z %%BST', tz.strftime('%Z %%Z %%%Z %%%%Z %%%%%Z', dt))
1262
1268
  assert_equal('+0100 +01:00 +01:00:00 +01 %::::z', tz.strftime('%z %:z %::z %:::z %::::z', dt))
1269
+ assert_equal('1153001522 %s %1153001522', tz.strftime('%s %%s %%%s', dt))
1263
1270
  end
1264
1271
 
1265
1272
  def test_strftime_time
@@ -1271,6 +1278,7 @@ class TCTimezone < Minitest::Test
1271
1278
  assert_equal('BST BST', tz.strftime('%Z %Z', t))
1272
1279
  assert_equal('BST %Z %BST %%Z %%BST', tz.strftime('%Z %%Z %%%Z %%%%Z %%%%%Z', t))
1273
1280
  assert_equal('+0100 +01:00 +01:00:00 +01 %::::z', tz.strftime('%z %:z %::z %:::z %::::z', t))
1281
+ assert_equal('1153001522 %s %1153001522', tz.strftime('%s %%s %%%s', t))
1274
1282
  end
1275
1283
 
1276
1284
  def test_strftime_int
@@ -1282,6 +1290,7 @@ class TCTimezone < Minitest::Test
1282
1290
  assert_equal('BST BST', tz.strftime('%Z %Z', i))
1283
1291
  assert_equal('BST %Z %BST %%Z %%BST', tz.strftime('%Z %%Z %%%Z %%%%Z %%%%%Z', i))
1284
1292
  assert_equal('+0100 +01:00 +01:00:00 +01 %::::z', tz.strftime('%z %:z %::z %:::z %::::z', i))
1293
+ assert_equal('1153001522 %s %1153001522', tz.strftime('%s %%s %%%s', i))
1285
1294
  end
1286
1295
 
1287
1296
  def test_get_missing_data_source
@@ -359,7 +359,17 @@ class TCTransitionDataTimezoneInfo < Minitest::Test
359
359
  assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,Rational(DATETIME_RESOLUTION,1000000))))
360
360
  assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1), DateTime.new(2010,4,1,1,0,0)))
361
361
  assert_equal([t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1), DateTime.new(2010,4,1,1,0,1)))
362
- assert_equal([t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1), DateTime.new(2010,4,1,1,0,Rational(DATETIME_RESOLUTION,1000000))))
362
+
363
+ # Ruby 1.8.7 (built with GCC 8.3.0 on Ubuntu 19.04) fails to perform
364
+ # DateTime comparisons correctly when sub-seconds are used.
365
+ to = DateTime.new(2011,10,1,1,0,1)
366
+ from = DateTime.new(2010,4,1,1,0,Rational(DATETIME_RESOLUTION,1000000))
367
+ if to > from
368
+ assert_equal([t2,t3,t4,t5], dti.transitions_up_to(to, from))
369
+ else
370
+ puts "This platform does not consider the DateTime #{to.strftime('%Y-%m-%d %H:%m:%S.%N')} to be later than the DateTime #{from.strftime('%Y-%m-%d %H:%m:%S.%N')}"
371
+ end
372
+
363
373
  assert_equal([t5], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0), DateTime.new(2011,10,1,1,0,0)))
364
374
  assert_equal([], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0), DateTime.new(2011,10,1,1,0,1)))
365
375
  end
@@ -7,6 +7,15 @@ require 'tmpdir'
7
7
 
8
8
  include TZInfo
9
9
 
10
+ # Use send as a workaround for an issue on JRuby 9.2.9.0 where using the
11
+ # refinement causes calls to RubyCoreSupport.file_open to fail to pass the block
12
+ # parameter.
13
+ #
14
+ # https://travis-ci.org/tzinfo/tzinfo/jobs/628812051#L1931
15
+ # https://github.com/jruby/jruby/issues/6009
16
+ send(:using, TZInfo::RubyCoreSupport::UntaintExt) if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)
17
+ send(:using, TaintExt) if Module.const_defined?(:TaintExt)
18
+
10
19
  class TCZoneinfoDataSource < Minitest::Test
11
20
  ZONEINFO_DIR = File.join(File.expand_path(File.dirname(__FILE__)), 'zoneinfo').untaint
12
21
 
@@ -653,7 +662,7 @@ class TCZoneinfoDataSource < Minitest::Test
653
662
  end
654
663
 
655
664
  def test_load_timezone_info_tainted
656
- safe_test do
665
+ safe_test(:unavailable => :skip) do
657
666
  identifier = 'Europe/Amsterdam'.dup.taint
658
667
  assert(identifier.tainted?)
659
668
  info = @data_source.load_timezone_info(identifier)
@@ -840,7 +849,7 @@ class TCZoneinfoDataSource < Minitest::Test
840
849
  end
841
850
 
842
851
  def test_load_country_info_tainted
843
- safe_test do
852
+ safe_test(:unavailable => :skip) do
844
853
  code = 'NL'.dup.taint
845
854
  assert(code.tainted?)
846
855
  info = @data_source.load_country_info(code)
@@ -5,6 +5,8 @@ require 'tempfile'
5
5
 
6
6
  include TZInfo
7
7
 
8
+ using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
9
+
8
10
  class TCZoneinfoTimezoneInfo < Minitest::Test
9
11
 
10
12
  begin
@@ -1,4 +1,6 @@
1
- TESTS_DIR = File.expand_path(File.dirname(__FILE__)).untaint
1
+ tests_dir = File.expand_path(File.dirname(__FILE__))
2
+ tests_dir.untaint if RUBY_VERSION < '2.7'
3
+ TESTS_DIR = tests_dir
2
4
  TZINFO_LIB_DIR = File.expand_path(File.join(TESTS_DIR, '..', 'lib'))
3
5
  TZINFO_TEST_DATA_DIR = File.join(TESTS_DIR, 'tzinfo-data')
4
6
  TZINFO_TEST_ZONEINFO_DIR = File.join(TESTS_DIR, 'zoneinfo')
@@ -55,8 +57,8 @@ module Kernel
55
57
  end
56
58
 
57
59
  def safe_test(options = {})
58
- # JRuby and Rubinus don't support SAFE levels.
59
- available = !(defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE))
60
+ # Ruby >= 2.7, JRuby and Rubinus don't support SAFE levels.
61
+ available = RUBY_VERSION < '2.7' && !(defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE))
60
62
 
61
63
  if available || options[:unavailable] != :skip
62
64
  thread = Thread.new do
@@ -96,6 +98,16 @@ module Kernel
96
98
  thread.join
97
99
  end
98
100
  end
101
+
102
+ def skip_if_has_bug_14060
103
+ # On Ruby 2.4.4 in safe mode, require will fail with a SecurityError for
104
+ # any file that has not previously been loaded, regardless of whether the
105
+ # file name is tainted.
106
+ # See https://bugs.ruby-lang.org/issues/14060#note-5.
107
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION == '2.4.4'
108
+ skip('Skipping test due to Ruby 2.4.4 being affected by Bug 14060 (see https://bugs.ruby-lang.org/issues/14060#note-5)')
109
+ end
110
+ end
99
111
 
100
112
  def assert_array_same_items(expected, actual, msg = nil)
101
113
  full_message = message(msg, '') { diff(expected, actual) }
@@ -152,6 +164,19 @@ module Kernel
152
164
  end
153
165
 
154
166
 
167
+ # Object#taint is a deprecated no-op in Ruby 2.7 and outputs a warning. It will
168
+ # be removed in 3.0. Silence the warning or supply a replacement.
169
+ if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)
170
+ module TaintExt
171
+ refine Object do
172
+ def taint
173
+ self
174
+ end
175
+ end
176
+ end
177
+ end
178
+
179
+
155
180
  # JRuby 1.7.5 to 1.7.9 consider DateTime instances that differ by less than
156
181
  # 1 millisecond to be equivalent (https://github.com/jruby/jruby/issues/1311).
157
182
  #
@@ -2,6 +2,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils.rb')
2
2
 
3
3
  # Use a zoneinfo directory containing files needed by the tests.
4
4
  # The symlinks in this directory are set up in test_utils.rb.
5
- TZInfo::DataSource.set(:zoneinfo, File.join(File.expand_path(File.dirname(__FILE__)), 'zoneinfo').untaint)
5
+ zoneinfo_path = File.join(File.expand_path(File.dirname(__FILE__)), 'zoneinfo')
6
+ zoneinfo_path.untaint if RUBY_VERSION < '2.7'
7
+ TZInfo::DataSource.set(:zoneinfo, zoneinfo_path)
6
8
 
7
9
  require File.join(File.expand_path(File.dirname(__FILE__)), 'ts_all.rb')
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'tzinfo'
3
- s.version = '1.2.5'
3
+ s.version = '1.2.6'
4
4
  s.summary = 'Daylight savings aware timezone library'
5
5
  s.description = 'TZInfo provides daylight savings aware transformations between times in different time zones.'
6
6
  s.author = 'Philip Ross'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Ross
@@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kqhkiG9w0BAQsFAAOCAQEA
25
+ J80xgZ3gGdQVA8N+8NJANU5HLuZIU9jOaAlziU9ImoTgPiOHKGZC4as1TwT4kBt1
26
+ Qcnu7YSANYRrxP5tpOHsWPF/MQYgerAFCZS5+PzOTudwZ+7OsMW4/EMHy6aCVHEd
27
+ c7HzQRC4mSrDRpWxzyBnZ5nX5OAmIkKA8NgeKybT/4Ku6iFPPUQwlyxQaO+Wlxdo
28
+ FqHwpjRyoiVSpe4RUTNK3d3qesWPYi7Lxn6k6ZZeEdvG6ya33AXktE3jmmF+jPR1
29
+ J3Zn/kSTjTekiaspyGbczC3PUaeJNxr+yCvR4sk71Xmk/GaKKGOHedJ1uj/LAXrA
30
+ MR0mpl7b8zCg0PFC1J73uw==
32
31
  -----END CERTIFICATE-----
33
- date: 2018-02-04 00:00:00.000000000 Z
32
+ date: 2019-12-24 00:00:00.000000000 Z
34
33
  dependencies:
35
34
  - !ruby/object:Gem::Dependency
36
35
  name: thread_safe
@@ -185,8 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
184
  - !ruby/object:Gem::Version
186
185
  version: '0'
187
186
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.7.4
187
+ rubygems_version: 3.1.2
190
188
  signing_key:
191
189
  specification_version: 4
192
190
  summary: Daylight savings aware timezone library
metadata.gz.sig CHANGED
Binary file