From 4723cf3731350519915d2f76a5d8b8e7d69f81e2 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 16 Dec 2019 17:17:13 +0100 Subject: [PATCH 1/5] Update rake --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 8156681b..e72cf3c9 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,6 @@ source "https://rubygems.org" gemspec group :test do - gem 'rake', '~> 10.5' + gem 'rake', '~> 13.0' gem 'minitest', '~> 5.0' end From 1b269bcf7439acecb4cdd8e80ea7ad5ea98762a1 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 16 Dec 2019 17:29:44 +0100 Subject: [PATCH 2/5] Fix taint related warnings on Ruby 2.7 --- lib/tzinfo.rb | 1 + lib/tzinfo/ruby_data_source.rb | 2 +- lib/tzinfo/zoneinfo_data_source.rb | 4 ++-- lib/tzinfo/zoneinfo_timezone_info.rb | 2 +- test/test_utils.rb | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/tzinfo.rb b/lib/tzinfo.rb index 0b64589b..1f19b14c 100644 --- a/lib/tzinfo.rb +++ b/lib/tzinfo.rb @@ -1,5 +1,6 @@ # Top level module for TZInfo. module TZInfo + TAINT_SUPPORT = RUBY_VERSION <= '2.7' end require 'tzinfo/ruby_core_support' diff --git a/lib/tzinfo/ruby_data_source.rb b/lib/tzinfo/ruby_data_source.rb index 2635c264..ed72c5e9 100644 --- a/lib/tzinfo/ruby_data_source.rb +++ b/lib/tzinfo/ruby_data_source.rb @@ -26,7 +26,7 @@ def load_timezone_info(identifier) # Untaint identifier after it has been reassigned to a new string. We # don't want to modify the original identifier. identifier may also be # frozen and therefore cannot be untainted. - identifier.untaint + identifier.untaint if TAINT_SUPPORT identifier = identifier.split('/') begin diff --git a/lib/tzinfo/zoneinfo_data_source.rb b/lib/tzinfo/zoneinfo_data_source.rb index b38fbf68..2c718303 100644 --- a/lib/tzinfo/zoneinfo_data_source.rb +++ b/lib/tzinfo/zoneinfo_data_source.rb @@ -197,7 +197,7 @@ def load_timezone_info(identifier) # Untaint path rather than identifier. We don't want to modify # identifier. identifier may also be frozen and therefore cannot be # untainted. - path.untaint + path.untaint if TAINT_SUPPORT begin ZoneinfoTimezoneInfo.new(identifier, path) @@ -364,7 +364,7 @@ def load_timezone_index def enum_timezones(dir, exclude = [], &block) Dir.foreach(dir ? File.join(@zoneinfo_dir, dir) : @zoneinfo_dir) do |entry| unless entry =~ /\./ || exclude.include?(entry) - entry.untaint + entry.untaint if TAINT_SUPPORT path = dir ? File.join(dir, entry) : entry full_path = File.join(@zoneinfo_dir, path) diff --git a/lib/tzinfo/zoneinfo_timezone_info.rb b/lib/tzinfo/zoneinfo_timezone_info.rb index d145614d..e846f25c 100644 --- a/lib/tzinfo/zoneinfo_timezone_info.rb +++ b/lib/tzinfo/zoneinfo_timezone_info.rb @@ -160,7 +160,7 @@ def define_offset(index, offset) std_offset = 0 end - offset index, utc_offset, std_offset, offset[:abbr].untaint.to_sym + offset index, utc_offset, std_offset, offset[:abbr].to_sym end # Parses a zoneinfo file and intializes the DataTimezoneInfo structures. diff --git a/test/test_utils.rb b/test/test_utils.rb index dba96d2e..edc72c68 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -1,4 +1,4 @@ -TESTS_DIR = File.expand_path(File.dirname(__FILE__)).untaint +TESTS_DIR = File.expand_path(File.dirname(__FILE__)) TZINFO_LIB_DIR = File.expand_path(File.join(TESTS_DIR, '..', 'lib')) TZINFO_TEST_DATA_DIR = File.join(TESTS_DIR, 'tzinfo-data') TZINFO_TEST_ZONEINFO_DIR = File.join(TESTS_DIR, 'zoneinfo') @@ -56,7 +56,7 @@ def without_warnings def safe_test(options = {}) # JRuby and Rubinus don't support SAFE levels. - available = !(defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE)) + available = !(defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE)) && RUBY_VERSION < '2.7' if available || options[:unavailable] != :skip thread = Thread.new do From 7a943b35597a6e891623a350ed454c69a395d203 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 16 Dec 2019 17:34:29 +0100 Subject: [PATCH 3/5] Fix keyword argument warning in open_file --- lib/tzinfo/ruby_core_support.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/tzinfo/ruby_core_support.rb b/lib/tzinfo/ruby_core_support.rb index c97819e1..92687b46 100644 --- a/lib/tzinfo/ruby_core_support.rb +++ b/lib/tzinfo/ruby_core_support.rb @@ -138,8 +138,11 @@ def self.open_file(file_name, mode, opts, &block) File.open(file_name, mode, &block) end else - def self.open_file(file_name, mode, opts, &block) - File.open(file_name, mode, opts, &block) + class << self + def open_file(file_name, mode, opts, &block) + ::File.open(file_name, mode, opts, &block) + end + ruby2_keywords :open_file if respond_to?(:ruby2_keywords, true) end end end From 4deddcdc0fc43982cd3f330886988e0ebeb731e3 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 16 Dec 2019 17:34:58 +0100 Subject: [PATCH 4/5] Test Ruby 2.7.0 on Travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6fe82483..abadac17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ rvm: - 2.3.7 - 2.4.4 - 2.5.1 + - 2.7.0 - ruby-head - jruby-18mode - jruby-1.7.27 From 71873adbf908def33a63723c80a11d589a44dcd7 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 16 Dec 2019 17:41:08 +0100 Subject: [PATCH 5/5] Conditionally untaint TESTS_DIR --- test/test_utils.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test_utils.rb b/test/test_utils.rb index edc72c68..d40aca07 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -1,4 +1,7 @@ -TESTS_DIR = File.expand_path(File.dirname(__FILE__)) +test_dir = File.expand_path(File.dirname(__FILE__)) +test_dir.untaint if RUBY_VERSION <= '2.7' +TESTS_DIR = test_dir + TZINFO_LIB_DIR = File.expand_path(File.join(TESTS_DIR, '..', 'lib')) TZINFO_TEST_DATA_DIR = File.join(TESTS_DIR, 'tzinfo-data') TZINFO_TEST_ZONEINFO_DIR = File.join(TESTS_DIR, 'zoneinfo')