psych 5.5.0 → 5.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/psych/depend +14 -3
- data/ext/psych/psych.h +4 -0
- data/ext/psych/psych_emitter.c +3 -3
- data/ext/psych/psych_parser.c +1 -1
- data/lib/psych/class_loader.rb +18 -0
- data/lib/psych/exception.rb +6 -0
- data/lib/psych/versions.rb +1 -1
- data/lib/psych/visitors/to_ruby.rb +14 -2
- data/lib/psych.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ec2c489fe8fc54cf54ff05de37a8475576bb3759856bd4fdf790b3c9aa4dbc5
|
|
4
|
+
data.tar.gz: 28743cd89e2d02277af5ea53013c86e4252eed4c8b953213a2d0f3be15054590
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4420b5daa4abc5b9943ba9253edeb38ecb510f7066a27ca78fe06e7027d36bfadef7eb69d2988948ff4206d3e94594e47b8896b4d3089d300279538367c9ede8
|
|
7
|
+
data.tar.gz: 9b53e8ff46470660697ec59c55ffddd8b5af24db9700468d63a276d3446c36a289f91359541a5bb4a4b62c52e382c6b0088352b0e1c28b034a66e53d25af2b2f
|
data/ext/psych/depend
CHANGED
|
@@ -12,6 +12,17 @@ distclean-so::
|
|
|
12
12
|
-cd libyaml && $(MAKE) distclean
|
|
13
13
|
-$(Q)$(RMDIRS) libyaml/* libyaml
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
# AUTOGENERATED DEPENDENCIES START
|
|
16
|
+
psych.o psych_emitter.o psych_emitter_fy.o psych_parser.o psych_parser_fy.o psych_to_ruby.o psych_yaml_tree.o: psych.h
|
|
17
|
+
psych.o psych_emitter.o psych_emitter_fy.o psych_parser.o psych_parser_fy.o psych_to_ruby.o psych_yaml_tree.o: psych_emitter.h
|
|
18
|
+
psych.o psych_emitter.o psych_emitter_fy.o psych_parser.o psych_parser_fy.o psych_to_ruby.o psych_yaml_tree.o: psych_parser.h
|
|
19
|
+
psych.o psych_emitter.o psych_emitter_fy.o psych_parser.o psych_parser_fy.o psych_to_ruby.o psych_yaml_tree.o: psych_to_ruby.h
|
|
20
|
+
psych.o psych_emitter.o psych_emitter_fy.o psych_parser.o psych_parser_fy.o psych_to_ruby.o psych_yaml_tree.o: psych_yaml_tree.h
|
|
21
|
+
psych.o: psych.c
|
|
22
|
+
psych_emitter.o: psych_emitter.c
|
|
23
|
+
psych_emitter_fy.o: psych_emitter_fy.c
|
|
24
|
+
psych_parser.o: psych_parser.c
|
|
25
|
+
psych_parser_fy.o: psych_parser_fy.c
|
|
26
|
+
psych_to_ruby.o: psych_to_ruby.c
|
|
27
|
+
psych_yaml_tree.o: psych_yaml_tree.c
|
|
28
|
+
# AUTOGENERATED DEPENDENCIES END
|
data/ext/psych/psych.h
CHANGED
data/ext/psych/psych_emitter.c
CHANGED
|
@@ -25,7 +25,7 @@ static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
|
|
|
25
25
|
static int writer(void *ctx, unsigned char *buffer, size_t size)
|
|
26
26
|
{
|
|
27
27
|
VALUE self = (VALUE)ctx, io = rb_attr_get(self, id_io);
|
|
28
|
-
VALUE str = rb_enc_str_new((const char *)buffer, (
|
|
28
|
+
VALUE str = rb_enc_str_new((const char *)buffer, (rb_len_t)size, rb_utf8_encoding());
|
|
29
29
|
VALUE wrote = rb_funcall(io, id_write, 1, str);
|
|
30
30
|
return (int)NUM2INT(wrote);
|
|
31
31
|
}
|
|
@@ -172,8 +172,8 @@ static VALUE start_document_try(VALUE d)
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
if(RTEST(tags)) {
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
rb_len_t i = 0;
|
|
176
|
+
rb_len_t len;
|
|
177
177
|
rb_encoding * encoding = rb_utf8_encoding();
|
|
178
178
|
|
|
179
179
|
Check_Type(tags, T_ARRAY);
|
data/ext/psych/psych_parser.c
CHANGED
|
@@ -419,7 +419,7 @@ static VALUE parse_body(VALUE ptr)
|
|
|
419
419
|
VALUE plain_implicit, quoted_implicit, style;
|
|
420
420
|
VALUE val = rb_str_new(
|
|
421
421
|
(const char *)event.data.scalar.value,
|
|
422
|
-
(
|
|
422
|
+
(rb_len_t)event.data.scalar.length
|
|
423
423
|
);
|
|
424
424
|
|
|
425
425
|
PSYCH_TRANSCODE(val, encoding, internal_enc);
|
data/lib/psych/class_loader.rb
CHANGED
|
@@ -35,6 +35,11 @@ module Psych
|
|
|
35
35
|
sym.to_sym
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
# Raises if instance variables may not be restored on +obj+. The
|
|
39
|
+
# unrestricted loader allows instance variables on any object.
|
|
40
|
+
def check_ivars obj
|
|
41
|
+
end
|
|
42
|
+
|
|
38
43
|
constants.each do |const|
|
|
39
44
|
konst = const_get const
|
|
40
45
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
|
@@ -76,6 +81,12 @@ module Psych
|
|
|
76
81
|
}.compact].freeze
|
|
77
82
|
|
|
78
83
|
class Restricted < ClassLoader
|
|
84
|
+
# Core classes whose instances must not have instance variables
|
|
85
|
+
# restored on them unless the class is explicitly permitted. Exact
|
|
86
|
+
# class match only, so permitted subclasses (for example a String
|
|
87
|
+
# subclass with its own ivars) still load.
|
|
88
|
+
BUILTIN_CLASSES = [::String, ::Hash].freeze
|
|
89
|
+
|
|
79
90
|
def initialize classes, symbols
|
|
80
91
|
@classes = classes
|
|
81
92
|
@symbols = symbols
|
|
@@ -92,6 +103,13 @@ module Psych
|
|
|
92
103
|
end
|
|
93
104
|
end
|
|
94
105
|
|
|
106
|
+
def check_ivars obj
|
|
107
|
+
klass = obj.class
|
|
108
|
+
if BUILTIN_CLASSES.include?(klass) && !@classes.include?(klass.name)
|
|
109
|
+
raise DisallowedInstanceVariables.new(klass.name)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
95
113
|
private
|
|
96
114
|
|
|
97
115
|
def find klassname
|
data/lib/psych/exception.rb
CHANGED
|
@@ -25,4 +25,10 @@ module Psych
|
|
|
25
25
|
super "Tried to #{action} unspecified class: #{klass_name}"
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
class DisallowedInstanceVariables < Exception
|
|
30
|
+
def initialize klass_name
|
|
31
|
+
super "Tried to set instance variables on unspecified class: #{klass_name}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
28
34
|
end
|
data/lib/psych/versions.rb
CHANGED
|
@@ -48,7 +48,9 @@ module Psych
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
# Classes and modules named by !ruby/class and !ruby/module are shared
|
|
52
|
+
# by the whole process, not created by this load, so leave them alone.
|
|
53
|
+
result = deduplicate(result).freeze if @freeze && !(Module === result)
|
|
52
54
|
result
|
|
53
55
|
end
|
|
54
56
|
|
|
@@ -259,6 +261,12 @@ module Psych
|
|
|
259
261
|
if klass
|
|
260
262
|
string = klass.allocate.replace value
|
|
261
263
|
else
|
|
264
|
+
# The value node can carry any tag, for example !ruby/class.
|
|
265
|
+
# Without this check the instance variables below would be
|
|
266
|
+
# set on whatever shared object that tag resolved to.
|
|
267
|
+
unless value.is_a?(String)
|
|
268
|
+
raise TypeError, "Invalid tag: expected a String for str, got #{value.class}"
|
|
269
|
+
end
|
|
262
270
|
string = value
|
|
263
271
|
end
|
|
264
272
|
register(o, string)
|
|
@@ -274,7 +282,9 @@ module Psych
|
|
|
274
282
|
members = Hash[o.children.map { |c| accept c }.each_slice(2).to_a]
|
|
275
283
|
list.replace members['internal']
|
|
276
284
|
|
|
277
|
-
members['ivars']
|
|
285
|
+
ivars = members['ivars']
|
|
286
|
+
class_loader.check_ivars(list) unless ivars.empty?
|
|
287
|
+
ivars.each do |ivar, v|
|
|
278
288
|
list.instance_variable_set ivar, v
|
|
279
289
|
end
|
|
280
290
|
list
|
|
@@ -309,6 +319,7 @@ module Psych
|
|
|
309
319
|
when 'elements'
|
|
310
320
|
revive_hash hash, value
|
|
311
321
|
when 'ivars'
|
|
322
|
+
class_loader.check_ivars(hash) unless value.children.empty?
|
|
312
323
|
value.children.each_slice(2) do |k,v|
|
|
313
324
|
hash.instance_variable_set accept(k), accept(v)
|
|
314
325
|
end
|
|
@@ -457,6 +468,7 @@ module Psych
|
|
|
457
468
|
if o.respond_to?(:init_with)
|
|
458
469
|
o.init_with c
|
|
459
470
|
else
|
|
471
|
+
class_loader.check_ivars(o) unless h.empty?
|
|
460
472
|
h.each { |k,v| o.instance_variable_set(:"@#{k}", v) }
|
|
461
473
|
end
|
|
462
474
|
o
|
data/lib/psych.rb
CHANGED
|
@@ -296,6 +296,17 @@ module Psych
|
|
|
296
296
|
#
|
|
297
297
|
# Now the Date class can be loaded in addition to the classes listed above.
|
|
298
298
|
#
|
|
299
|
+
# Instance variables are not restored on String or Hash objects unless
|
|
300
|
+
# String or Hash is listed in +permitted_classes+; otherwise a
|
|
301
|
+
# Psych::DisallowedInstanceVariables exception is raised.
|
|
302
|
+
#
|
|
303
|
+
# Permitting a class lets the YAML set arbitrary instance variables on
|
|
304
|
+
# instances of that class. Each new instance variable name creates a
|
|
305
|
+
# symbol that is never garbage collected, so untrusted input loaded with
|
|
306
|
+
# +permitted_classes+ can grow memory without bound. Validate untrusted
|
|
307
|
+
# YAML against a schema before loading it, for example with the
|
|
308
|
+
# yaml-schema gem (https://github.com/tenderlove/yaml-schema).
|
|
309
|
+
#
|
|
299
310
|
# Aliases can be explicitly allowed by changing the +aliases+ keyword argument.
|
|
300
311
|
# For example:
|
|
301
312
|
#
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: psych
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.5.
|
|
4
|
+
version: 5.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aaron Patterson
|
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
127
127
|
- !ruby/object:Gem::Version
|
|
128
128
|
version: '0'
|
|
129
129
|
requirements: []
|
|
130
|
-
rubygems_version:
|
|
130
|
+
rubygems_version: 4.0.20
|
|
131
131
|
specification_version: 4
|
|
132
132
|
summary: Psych is a YAML parser and emitter
|
|
133
133
|
test_files: []
|