psych 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.travis.yml +1 -10
- data/Gemfile +3 -0
- data/Mavenfile +7 -0
- data/Rakefile +27 -119
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/ext/java/PsychEmitter.java +345 -0
- data/ext/java/PsychLibrary.java +93 -0
- data/ext/java/PsychParser.java +399 -0
- data/ext/java/PsychToRuby.java +79 -0
- data/ext/java/PsychYamlTree.java +55 -0
- data/ext/psych/.gitignore +11 -0
- data/lib/psych.rb +2 -2
- data/lib/psych/scalar_scanner.rb +1 -1
- data/lib/psych/visitors/to_ruby.rb +2 -2
- data/psych.gemspec +39 -0
- metadata +21 -84
- data/.autotest +0 -18
- data/Manifest.txt +0 -114
- data/test/psych/handlers/test_recorder.rb +0 -26
- data/test/psych/helper.rb +0 -122
- data/test/psych/json/test_stream.rb +0 -110
- data/test/psych/nodes/test_enumerable.rb +0 -44
- data/test/psych/test_alias_and_anchor.rb +0 -97
- data/test/psych/test_array.rb +0 -58
- data/test/psych/test_boolean.rb +0 -37
- data/test/psych/test_class.rb +0 -37
- data/test/psych/test_coder.rb +0 -207
- data/test/psych/test_date_time.rb +0 -39
- data/test/psych/test_deprecated.rb +0 -215
- data/test/psych/test_document.rb +0 -47
- data/test/psych/test_emitter.rb +0 -111
- data/test/psych/test_encoding.rb +0 -269
- data/test/psych/test_exception.rb +0 -158
- data/test/psych/test_hash.rb +0 -95
- data/test/psych/test_json_tree.rb +0 -66
- data/test/psych/test_merge_keys.rb +0 -181
- data/test/psych/test_nil.rb +0 -19
- data/test/psych/test_null.rb +0 -20
- data/test/psych/test_numeric.rb +0 -46
- data/test/psych/test_object.rb +0 -45
- data/test/psych/test_object_references.rb +0 -72
- data/test/psych/test_omap.rb +0 -76
- data/test/psych/test_parser.rb +0 -340
- data/test/psych/test_psych.rb +0 -184
- data/test/psych/test_safe_load.rb +0 -98
- data/test/psych/test_scalar.rb +0 -12
- data/test/psych/test_scalar_scanner.rb +0 -107
- data/test/psych/test_serialize_subclasses.rb +0 -39
- data/test/psych/test_set.rb +0 -50
- data/test/psych/test_stream.rb +0 -94
- data/test/psych/test_string.rb +0 -227
- data/test/psych/test_struct.rb +0 -50
- data/test/psych/test_symbol.rb +0 -26
- data/test/psych/test_tainted.rb +0 -131
- data/test/psych/test_to_yaml_properties.rb +0 -64
- data/test/psych/test_tree_builder.rb +0 -80
- data/test/psych/test_yaml.rb +0 -1293
- data/test/psych/test_yamldbm.rb +0 -193
- data/test/psych/test_yamlstore.rb +0 -86
- data/test/psych/visitors/test_depth_first.rb +0 -50
- data/test/psych/visitors/test_emitter.rb +0 -145
- data/test/psych/visitors/test_to_ruby.rb +0 -332
- data/test/psych/visitors/test_yaml_tree.rb +0 -180
data/test/psych/test_stream.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative 'helper'
|
3
|
-
|
4
|
-
module Psych
|
5
|
-
class TestStream < TestCase
|
6
|
-
def test_parse_partial
|
7
|
-
rb = Psych.parse("--- foo\n...\n--- `").to_ruby
|
8
|
-
assert_equal 'foo', rb
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_load_partial
|
12
|
-
rb = Psych.load("--- foo\n...\n--- `")
|
13
|
-
assert_equal 'foo', rb
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_parse_stream_yields_documents
|
17
|
-
list = []
|
18
|
-
Psych.parse_stream("--- foo\n...\n--- bar") do |doc|
|
19
|
-
list << doc.to_ruby
|
20
|
-
end
|
21
|
-
assert_equal %w{ foo bar }, list
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_parse_stream_break
|
25
|
-
list = []
|
26
|
-
Psych.parse_stream("--- foo\n...\n--- `") do |doc|
|
27
|
-
list << doc.to_ruby
|
28
|
-
break
|
29
|
-
end
|
30
|
-
assert_equal %w{ foo }, list
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_load_stream_yields_documents
|
34
|
-
list = []
|
35
|
-
Psych.load_stream("--- foo\n...\n--- bar") do |ruby|
|
36
|
-
list << ruby
|
37
|
-
end
|
38
|
-
assert_equal %w{ foo bar }, list
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_load_stream_break
|
42
|
-
list = []
|
43
|
-
Psych.load_stream("--- foo\n...\n--- `") do |ruby|
|
44
|
-
list << ruby
|
45
|
-
break
|
46
|
-
end
|
47
|
-
assert_equal %w{ foo }, list
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_explicit_documents
|
51
|
-
io = StringIO.new
|
52
|
-
stream = Psych::Stream.new(io)
|
53
|
-
stream.start
|
54
|
-
stream.push({ 'foo' => 'bar' })
|
55
|
-
|
56
|
-
assert !stream.finished?, 'stream not finished'
|
57
|
-
stream.finish
|
58
|
-
assert stream.finished?, 'stream finished'
|
59
|
-
|
60
|
-
assert_match(/^---/, io.string)
|
61
|
-
assert_match(/\.\.\.$/, io.string)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_start_takes_block
|
65
|
-
io = StringIO.new
|
66
|
-
stream = Psych::Stream.new(io)
|
67
|
-
stream.start do |emitter|
|
68
|
-
emitter.push({ 'foo' => 'bar' })
|
69
|
-
end
|
70
|
-
|
71
|
-
assert stream.finished?, 'stream finished'
|
72
|
-
assert_match(/^---/, io.string)
|
73
|
-
assert_match(/\.\.\.$/, io.string)
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_no_backreferences
|
77
|
-
io = StringIO.new
|
78
|
-
stream = Psych::Stream.new(io)
|
79
|
-
stream.start do |emitter|
|
80
|
-
x = { 'foo' => 'bar' }
|
81
|
-
emitter.push x
|
82
|
-
emitter.push x
|
83
|
-
end
|
84
|
-
|
85
|
-
assert stream.finished?, 'stream finished'
|
86
|
-
assert_match(/^---/, io.string)
|
87
|
-
assert_match(/\.\.\.$/, io.string)
|
88
|
-
assert_equal 2, io.string.scan('---').length
|
89
|
-
assert_equal 2, io.string.scan('...').length
|
90
|
-
assert_equal 2, io.string.scan('foo').length
|
91
|
-
assert_equal 2, io.string.scan('bar').length
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
data/test/psych/test_string.rb
DELETED
@@ -1,227 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# frozen_string_literal: false
|
3
|
-
require_relative 'helper'
|
4
|
-
|
5
|
-
module Psych
|
6
|
-
class TestString < TestCase
|
7
|
-
class X < String
|
8
|
-
end
|
9
|
-
|
10
|
-
class Y < String
|
11
|
-
attr_accessor :val
|
12
|
-
end
|
13
|
-
|
14
|
-
class Z < String
|
15
|
-
def initialize
|
16
|
-
force_encoding Encoding::US_ASCII
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_string_with_newline
|
21
|
-
assert_equal "1\n2", Psych.load("--- ! '1\n\n 2'\n")
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_no_doublequotes_with_special_characters
|
25
|
-
assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"')
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_no_quotes_when_start_with_non_ascii_character
|
29
|
-
yaml = Psych.dump 'Český non-ASCII'.encode(Encoding::UTF_8)
|
30
|
-
assert_match(/---\s*[^"'!]+$/, yaml)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_doublequotes_when_there_is_a_single
|
34
|
-
str = "@123'abc"
|
35
|
-
yaml = Psych.dump str
|
36
|
-
assert_match /---\s*"/, yaml
|
37
|
-
assert_equal str, Psych.load(yaml)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_plain_when_shorten_than_line_width_and_no_final_line_break
|
41
|
-
str = "Lorem ipsum"
|
42
|
-
yaml = Psych.dump str, line_width: 12
|
43
|
-
assert_match /---\s*[^>|]+\n/, yaml
|
44
|
-
assert_equal str, Psych.load(yaml)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_plain_when_shorten_than_line_width_and_with_final_line_break
|
48
|
-
str = "Lorem ipsum\n"
|
49
|
-
yaml = Psych.dump str, line_width: 12
|
50
|
-
assert_match /---\s*[^>|]+\n/, yaml
|
51
|
-
assert_equal str, Psych.load(yaml)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_folded_when_longer_than_line_width_and_with_final_line_break
|
55
|
-
str = "Lorem ipsum dolor sit\n"
|
56
|
-
yaml = Psych.dump str, line_width: 12
|
57
|
-
assert_match /---\s*>\n(.*\n){2}\Z/, yaml
|
58
|
-
assert_equal str, Psych.load(yaml)
|
59
|
-
end
|
60
|
-
|
61
|
-
# http://yaml.org/spec/1.2/2009-07-21/spec.html#id2593651
|
62
|
-
def test_folded_strip_when_longer_than_line_width_and_no_newlines
|
63
|
-
str = "Lorem ipsum dolor sit amet, consectetur"
|
64
|
-
yaml = Psych.dump str, line_width: 12
|
65
|
-
assert_match /---\s*>-\n(.*\n){3}\Z/, yaml
|
66
|
-
assert_equal str, Psych.load(yaml)
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_literal_when_inner_and_final_line_break
|
70
|
-
[
|
71
|
-
"Lorem ipsum\ndolor\n",
|
72
|
-
"Lorem ipsum\nZolor\n",
|
73
|
-
].each do |str|
|
74
|
-
yaml = Psych.dump str, line_width: 12
|
75
|
-
assert_match /---\s*\|\n(.*\n){2}\Z/, yaml
|
76
|
-
assert_equal str, Psych.load(yaml)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# http://yaml.org/spec/1.2/2009-07-21/spec.html#id2593651
|
81
|
-
def test_literal_strip_when_inner_line_break_and_no_final_line_break
|
82
|
-
[
|
83
|
-
"Lorem ipsum\ndolor",
|
84
|
-
"Lorem ipsum\nZolor",
|
85
|
-
].each do |str|
|
86
|
-
yaml = Psych.dump str, line_width: 12
|
87
|
-
assert_match /---\s*\|-\n(.*\n){2}\Z/, yaml
|
88
|
-
assert_equal str, Psych.load(yaml)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_cycle_x
|
93
|
-
str = X.new 'abc'
|
94
|
-
assert_cycle str
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_dash_dot
|
98
|
-
assert_cycle '-.'
|
99
|
-
assert_cycle '+.'
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_string_subclass_with_anchor
|
103
|
-
y = Psych.load <<-eoyml
|
104
|
-
---
|
105
|
-
body:
|
106
|
-
string: &70121654388580 !ruby/string
|
107
|
-
str: ! 'foo'
|
108
|
-
x:
|
109
|
-
body: *70121654388580
|
110
|
-
eoyml
|
111
|
-
assert_equal({"body"=>{"string"=>"foo", "x"=>{"body"=>"foo"}}}, y)
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_self_referential_string
|
115
|
-
y = Psych.load <<-eoyml
|
116
|
-
---
|
117
|
-
string: &70121654388580 !ruby/string
|
118
|
-
str: ! 'foo'
|
119
|
-
body: *70121654388580
|
120
|
-
eoyml
|
121
|
-
|
122
|
-
assert_equal({"string"=>"foo"}, y)
|
123
|
-
value = y['string']
|
124
|
-
assert_equal value, value.instance_variable_get(:@body)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_another_subclass_with_attributes
|
128
|
-
y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1}
|
129
|
-
assert_equal "foo", y
|
130
|
-
assert_equal Y, y.class
|
131
|
-
assert_equal 1, y.val
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_backwards_with_syck
|
135
|
-
x = Psych.load "--- !str:#{X.name} foo\n\n"
|
136
|
-
assert_equal X, x.class
|
137
|
-
assert_equal 'foo', x
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_empty_subclass
|
141
|
-
assert_match "!ruby/string:#{X}", Psych.dump(X.new)
|
142
|
-
x = Psych.load Psych.dump X.new
|
143
|
-
assert_equal X, x.class
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_empty_character_subclass
|
147
|
-
assert_match "!ruby/string:#{Z}", Psych.dump(Z.new)
|
148
|
-
x = Psych.load Psych.dump Z.new
|
149
|
-
assert_equal Z, x.class
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_subclass_with_attributes
|
153
|
-
y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1}
|
154
|
-
assert_equal Y, y.class
|
155
|
-
assert_equal 1, y.val
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_string_with_base_60
|
159
|
-
yaml = Psych.dump '01:03:05'
|
160
|
-
assert_match "'01:03:05'", yaml
|
161
|
-
assert_equal '01:03:05', Psych.load(yaml)
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_nonascii_string_as_binary
|
165
|
-
string = "hello \x80 world!"
|
166
|
-
string.force_encoding 'ascii-8bit'
|
167
|
-
yml = Psych.dump string
|
168
|
-
assert_match(/binary/, yml)
|
169
|
-
assert_equal string, Psych.load(yml)
|
170
|
-
end
|
171
|
-
|
172
|
-
def test_binary_string_null
|
173
|
-
string = "\x00"
|
174
|
-
yml = Psych.dump string
|
175
|
-
assert_match(/binary/, yml)
|
176
|
-
assert_equal string, Psych.load(yml)
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_binary_string
|
180
|
-
string = binary_string
|
181
|
-
yml = Psych.dump string
|
182
|
-
assert_match(/binary/, yml)
|
183
|
-
assert_equal string, Psych.load(yml)
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_non_binary_string
|
187
|
-
string = binary_string(0.29)
|
188
|
-
yml = Psych.dump string
|
189
|
-
refute_match(/binary/, yml)
|
190
|
-
assert_equal string, Psych.load(yml)
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_ascii_only_8bit_string
|
194
|
-
string = "abc".encode(Encoding::ASCII_8BIT)
|
195
|
-
yml = Psych.dump string
|
196
|
-
refute_match(/binary/, yml)
|
197
|
-
assert_equal string, Psych.load(yml)
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_string_with_ivars
|
201
|
-
food = "is delicious"
|
202
|
-
ivar = "on rock and roll"
|
203
|
-
food.instance_variable_set(:@we_built_this_city, ivar)
|
204
|
-
|
205
|
-
Psych.load Psych.dump food
|
206
|
-
assert_equal ivar, food.instance_variable_get(:@we_built_this_city)
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_binary
|
210
|
-
string = [0, 123,22, 44, 9, 32, 34, 39].pack('C*')
|
211
|
-
assert_cycle string
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_float_confusion
|
215
|
-
assert_cycle '1.'
|
216
|
-
end
|
217
|
-
|
218
|
-
def binary_string percentage = 0.31, length = 100
|
219
|
-
string = ''
|
220
|
-
(percentage * length).to_i.times do |i|
|
221
|
-
string << "\b"
|
222
|
-
end
|
223
|
-
string << 'a' * (length - string.length)
|
224
|
-
string
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
data/test/psych/test_struct.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative 'helper'
|
3
|
-
|
4
|
-
class PsychStructWithIvar < Struct.new(:foo)
|
5
|
-
attr_reader :bar
|
6
|
-
def initialize *args
|
7
|
-
super
|
8
|
-
@bar = 'hello'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
module Psych
|
13
|
-
class TestStruct < TestCase
|
14
|
-
class StructSubclass < Struct.new(:foo)
|
15
|
-
def initialize foo, bar
|
16
|
-
super(foo)
|
17
|
-
@bar = bar
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_self_referential_struct
|
22
|
-
ss = StructSubclass.new(nil, 'foo')
|
23
|
-
ss.foo = ss
|
24
|
-
|
25
|
-
loaded = Psych.load(Psych.dump(ss))
|
26
|
-
assert_instance_of(StructSubclass, loaded.foo)
|
27
|
-
|
28
|
-
assert_equal(ss, loaded)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_roundtrip
|
32
|
-
thing = PsychStructWithIvar.new('bar')
|
33
|
-
struct = Psych.load(Psych.dump(thing))
|
34
|
-
|
35
|
-
assert_equal 'hello', struct.bar
|
36
|
-
assert_equal 'bar', struct.foo
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_load
|
40
|
-
obj = Psych.load(<<-eoyml)
|
41
|
-
--- !ruby/struct:PsychStructWithIvar
|
42
|
-
:foo: bar
|
43
|
-
:@bar: hello
|
44
|
-
eoyml
|
45
|
-
|
46
|
-
assert_equal 'hello', obj.bar
|
47
|
-
assert_equal 'bar', obj.foo
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/test/psych/test_symbol.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative 'helper'
|
3
|
-
|
4
|
-
module Psych
|
5
|
-
class TestSymbol < TestCase
|
6
|
-
def test_cycle_empty
|
7
|
-
assert_cycle :''
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_cycle_colon
|
11
|
-
assert_cycle :':'
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_cycle
|
15
|
-
assert_cycle :a
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_stringy
|
19
|
-
assert_cycle :"1"
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_load_quoted
|
23
|
-
assert_equal :"1", Psych.load("--- :'1'\n")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/test/psych/test_tainted.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require_relative 'helper'
|
3
|
-
|
4
|
-
module Psych
|
5
|
-
class TestStringTainted < TestCase
|
6
|
-
class Tainted < Handler
|
7
|
-
attr_reader :tc
|
8
|
-
|
9
|
-
def initialize tc
|
10
|
-
@tc = tc
|
11
|
-
end
|
12
|
-
|
13
|
-
def start_document version, tags, implicit
|
14
|
-
tags.flatten.each do |tag|
|
15
|
-
assert_taintedness tag
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def alias name
|
20
|
-
assert_taintedness name
|
21
|
-
end
|
22
|
-
|
23
|
-
def scalar value, anchor, tag, plain, quoted, style
|
24
|
-
assert_taintedness value
|
25
|
-
assert_taintedness tag if tag
|
26
|
-
assert_taintedness anchor if anchor
|
27
|
-
end
|
28
|
-
|
29
|
-
def start_sequence anchor, tag, implicit, style
|
30
|
-
assert_taintedness tag if tag
|
31
|
-
assert_taintedness anchor if anchor
|
32
|
-
end
|
33
|
-
|
34
|
-
def start_mapping anchor, tag, implicit, style
|
35
|
-
assert_taintedness tag if tag
|
36
|
-
assert_taintedness anchor if anchor
|
37
|
-
end
|
38
|
-
|
39
|
-
def assert_taintedness thing, message = "'#{thing}' should be tainted"
|
40
|
-
tc.assert thing.tainted?, message
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class Untainted < Tainted
|
45
|
-
def assert_taintedness thing, message = "'#{thing}' should not be tainted"
|
46
|
-
tc.assert !thing.tainted?, message
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
def setup
|
52
|
-
handler = Tainted.new self
|
53
|
-
@parser = Psych::Parser.new handler
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_tags_are_tainted
|
57
|
-
assert_taintedness "%TAG !yaml! tag:yaml.org,2002:\n---\n!yaml!str \"foo\""
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_alias
|
61
|
-
assert_taintedness "--- &ponies\n- foo\n- *ponies"
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_scalar
|
65
|
-
assert_taintedness "--- ponies"
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_anchor
|
69
|
-
assert_taintedness "--- &hi ponies"
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_scalar_tag
|
73
|
-
assert_taintedness "--- !str ponies"
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_seq_start_tag
|
77
|
-
assert_taintedness "--- !!seq [ a ]"
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_seq_start_anchor
|
81
|
-
assert_taintedness "--- &zomg [ a ]"
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_seq_mapping_tag
|
85
|
-
assert_taintedness "--- !!map { a: b }"
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_seq_mapping_anchor
|
89
|
-
assert_taintedness "--- &himom { a: b }"
|
90
|
-
end
|
91
|
-
|
92
|
-
def assert_taintedness string
|
93
|
-
@parser.parse string.taint
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
class TestStringUntainted < TestStringTainted
|
98
|
-
def setup
|
99
|
-
handler = Untainted.new self
|
100
|
-
@parser = Psych::Parser.new handler
|
101
|
-
end
|
102
|
-
|
103
|
-
def assert_taintedness string
|
104
|
-
@parser.parse string
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
class TestStringIOUntainted < TestStringTainted
|
109
|
-
def setup
|
110
|
-
handler = Untainted.new self
|
111
|
-
@parser = Psych::Parser.new handler
|
112
|
-
end
|
113
|
-
|
114
|
-
def assert_taintedness string
|
115
|
-
@parser.parse StringIO.new(string)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
class TestIOTainted < TestStringTainted
|
120
|
-
def assert_taintedness string
|
121
|
-
Tempfile.create(['something', 'yml']) {|t|
|
122
|
-
t.binmode
|
123
|
-
t.write string
|
124
|
-
t.close
|
125
|
-
File.open(t.path, 'r:bom|utf-8') { |f|
|
126
|
-
@parser.parse f
|
127
|
-
}
|
128
|
-
}
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|