Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate Object#untaint deprecation warnings when running on JRuby 9.4.
Despite the UntaintExt refinement that replaces Object#untaint being used, JRuby 9.4 calls the original Object#untaint method and outputs warnings as a result: warning: Object#untaint is deprecated and will be removed in Ruby 3.2 This is caused by the unorthodox `send(:using, UntaintExt)` approach being used to deal with issues with older JRuby versions (see #114). Replace the UntaintExt refinement with an untaint method in the now reinstanted RubyCoreSupport module. Change test cases to skip when taint/untaint is undefined or a no-op. There's no point in running these tests without inputs that are tainted. Remove the (test-only) TaintExt refinement too. Resolves #145.
- Loading branch information
Showing
15 changed files
with
121 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module TZInfo | ||
|
||
# Methods to support different versions of Ruby. | ||
# | ||
# @private | ||
module RubyCoreSupport #:nodoc: | ||
class << self | ||
# Object#untaint is deprecated and becomes a no-op in Ruby >= 2.7. It has | ||
# been removed from 3.2. | ||
if !Object.new.respond_to?(:untaint) || RUBY_VERSION =~ /\A(\d+)\.(\d+)(?:\.|\z)/ && ($1 == '2' && $2.to_i >= 7 || $1.to_i >= 3) | ||
# :nocov_functional_untaint: | ||
|
||
# Returns the supplied `Object` | ||
# | ||
# @param o [Object] the `Object` to untaint. | ||
# @return [Object] `o`. | ||
def untaint(o) | ||
o | ||
end | ||
|
||
# :nocov_functional_untaint: | ||
else | ||
# :nocov_no_functional_untaint: | ||
|
||
# Untaints and returns the supplied `Object`. | ||
# | ||
# @param o [Object] the `Object` to untaint. | ||
# @return [Object] `o`. | ||
def untaint(o) | ||
o.untaint | ||
end | ||
|
||
# :nocov_no_functional_untaint: | ||
end | ||
end | ||
end | ||
private_constant :RubyCoreSupport | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# encoding: UTF-8 | ||
# frozen_string_literal: true | ||
|
||
require_relative 'test_utils' | ||
|
||
class TCRubyCoreSupport < Minitest::Test | ||
def test_untaint_returns_object | ||
o = Object.new | ||
assert_same(o, TZInfo.const_get(:RubyCoreSupport).untaint(o)) | ||
end | ||
|
||
def test_untaint_untaints_object | ||
skip_if_taint_is_undefined_or_no_op | ||
o = Object.new.taint | ||
assert(o.tainted?) | ||
TZInfo.const_get(:RubyCoreSupport).untaint(o) | ||
refute(o.tainted?) | ||
end | ||
end |
Oops, something went wrong.