summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-10-18 12:34:59 -0700
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-12 10:35:47 +0900
commit30fdee65d96924e0793ec702fcda909a2cac71ea (patch)
tree9f92bbd2e5db5fc62fc85a5459de678eb66f56ae /test/psych
parent5ef41c91f0a1bca1617aaa4367ccf8e32c04b2d9 (diff)
[ruby/psych] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect. The lack of taint support should not cause a problem in previous Ruby versions. I'm not sure if the untaint calls in deduplicate are still needed after the removal of tainting in the parser. If they are not needed, they should be removed. https://github.com/ruby/psych/commit/73c1a2b4e0
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/test_tainted.rb131
1 files changed, 0 insertions, 131 deletions
diff --git a/test/psych/test_tainted.rb b/test/psych/test_tainted.rb
deleted file mode 100644
index dcf150b138..0000000000
--- a/test/psych/test_tainted.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-# frozen_string_literal: true
-require_relative 'helper'
-
-module Psych
- class TestStringTainted < TestCase
- class Tainted < Handler
- attr_reader :tc
-
- def initialize tc
- @tc = tc
- end
-
- def start_document version, tags, implicit
- tags.flatten.each do |tag|
- assert_taintedness tag
- end
- end
-
- def alias name
- assert_taintedness name
- end
-
- def scalar value, anchor, tag, plain, quoted, style
- assert_taintedness value
- assert_taintedness tag if tag
- assert_taintedness anchor if anchor
- end
-
- def start_sequence anchor, tag, implicit, style
- assert_taintedness tag if tag
- assert_taintedness anchor if anchor
- end
-
- def start_mapping anchor, tag, implicit, style
- assert_taintedness tag if tag
- assert_taintedness anchor if anchor
- end
-
- def assert_taintedness thing, message = "'#{thing}' should be tainted"
- tc.assert thing.tainted?, message
- end
- end
-
- class Untainted < Tainted
- def assert_taintedness thing, message = "'#{thing}' should not be tainted"
- tc.assert !thing.tainted?, message
- end
- end
-
-
- def setup
- handler = Tainted.new self
- @parser = Psych::Parser.new handler
- end
-
- def test_tags_are_tainted
- assert_taintedness "%TAG !yaml! tag:yaml.org,2002:\n---\n!yaml!str \"foo\""
- end
-
- def test_alias
- assert_taintedness "--- &ponies\n- foo\n- *ponies"
- end
-
- def test_scalar
- assert_taintedness "--- ponies"
- end
-
- def test_anchor
- assert_taintedness "--- &hi ponies"
- end
-
- def test_scalar_tag
- assert_taintedness "--- !str ponies"
- end
-
- def test_seq_start_tag
- assert_taintedness "--- !!seq [ a ]"
- end
-
- def test_seq_start_anchor
- assert_taintedness "--- &zomg [ a ]"
- end
-
- def test_seq_mapping_tag
- assert_taintedness "--- !!map { a: b }"
- end
-
- def test_seq_mapping_anchor
- assert_taintedness "--- &himom { a: b }"
- end
-
- def assert_taintedness string
- @parser.parse string.dup.taint
- end
- end
-
- class TestStringUntainted < TestStringTainted
- def setup
- handler = Untainted.new self
- @parser = Psych::Parser.new handler
- end
-
- def assert_taintedness string
- @parser.parse string
- end
- end
-
- class TestStringIOUntainted < TestStringTainted
- def setup
- handler = Untainted.new self
- @parser = Psych::Parser.new handler
- end
-
- def assert_taintedness string
- @parser.parse StringIO.new(string)
- end
- end
-
- class TestIOTainted < TestStringTainted
- def assert_taintedness string
- Tempfile.create(['something', 'yml']) {|t|
- t.binmode
- t.write string
- t.close
- File.open(t.path, 'r:bom|utf-8') { |f|
- @parser.parse f
- }
- }
- end
- end
-end