psych 3.0.3-x86-mingw32 → 3.1.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -5
- data/CHANGELOG.rdoc +7 -0
- data/README.md +1 -1
- data/Rakefile +4 -4
- data/ext/psych/yaml/api.c +26 -25
- data/ext/psych/yaml/config.h +5 -5
- data/ext/psych/yaml/dumper.c +2 -2
- data/ext/psych/yaml/emitter.c +4 -9
- data/ext/psych/yaml/loader.c +4 -4
- data/ext/psych/yaml/parser.c +5 -5
- data/ext/psych/yaml/reader.c +3 -3
- data/ext/psych/yaml/scanner.c +11 -7
- data/ext/psych/yaml/yaml_private.h +43 -17
- data/lib/psych.rb +113 -41
- data/lib/psych/handler.rb +1 -1
- data/lib/psych/versions.rb +3 -2
- data/psych.gemspec +18 -6
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: af19e6a50119e52d94b9ab8afc74c32b042d2a7c03401d80a3eb3b3ee526907c
|
4
|
+
data.tar.gz: 2a95874e258ceecf0bb12fa67ef47a07c445e6d15f91e9301a77217770df9bdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a89691880b46417bd0a9b63fb405571f490f01fd63b6340ba3eabdc558c2eb50fab8fdb18a004608a26a853352f9b028f037816d358e1ffc795ef344c2bfe589
|
7
|
+
data.tar.gz: c8861e15d0ef5d44389069177b769a5608a832fd8ea93e5ff432f2e2a162b6bc1e3971c0415440c890d07eab82d5ea2e40eb8e35723312e34b480a4ca4f6801c
|
data/.travis.yml
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
rvm:
|
2
|
-
- 2.
|
3
|
-
- 2.
|
4
|
-
- 2.
|
2
|
+
- 2.3.8
|
3
|
+
- 2.4.5
|
4
|
+
- 2.5.3
|
5
5
|
- ruby-head
|
6
|
-
- jruby-9.1.
|
6
|
+
- jruby-9.1.17.0
|
7
|
+
- jruby-9.2.0.0
|
7
8
|
|
8
9
|
matrix:
|
9
10
|
allow_failures:
|
10
|
-
- rvm: jruby-9.1.
|
11
|
+
- rvm: jruby-9.1.17.0
|
12
|
+
- rvm: jruby-9.2.0.0
|
11
13
|
|
12
14
|
before_script:
|
13
15
|
- unset JRUBY_OPTS
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Thu Nov 8 12:00:00 2018 Juanito Fatas <me@juanitofatas.com>
|
2
|
+
|
3
|
+
* lib/psych.rb: Use friendlier terminology in YAML.safe_load.
|
4
|
+
Replace keyword argumment whitelist_classes and whitelist_symbols.
|
5
|
+
with permitted_classes and permitted_symbols.
|
6
|
+
* test/psych/test_safer_load.rb: Update tests accordingly.
|
7
|
+
|
1
8
|
Fri Feb 6 17:47:05 2015 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
9
|
|
3
10
|
* ext/psych/lib/psych/visitors/yaml_tree.rb: register nodes when
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
## Description
|
9
9
|
|
10
10
|
Psych is a YAML parser and emitter. Psych leverages
|
11
|
-
[libyaml](
|
11
|
+
[libyaml](https://pyyaml.org/wiki/LibYAML) for its YAML parsing and emitting
|
12
12
|
capabilities. In addition to wrapping libyaml, Psych also knows how to
|
13
13
|
serialize and de-serialize most Ruby objects to and from the YAML format.
|
14
14
|
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ if RUBY_PLATFORM =~ /java/
|
|
20
20
|
# and tell maven via system properties the snakeyaml version
|
21
21
|
# this is basically the same as running from the commandline:
|
22
22
|
# rmvn dependency:build-classpath -Dsnakeyaml.version='use version from Psych::DEFAULT_SNAKEYAML_VERSION here'
|
23
|
-
Maven::Ruby::Maven.new.exec('dependency:build-classpath', "-Dsnakeyaml.version
|
23
|
+
Maven::Ruby::Maven.new.exec('dependency:build-classpath', "-Dsnakeyaml.version=#{Psych::DEFAULT_SNAKEYAML_VERSION}", '-Dverbose=true')
|
24
24
|
ext.source_version = '1.7'
|
25
25
|
ext.target_version = '1.7'
|
26
26
|
ext.classpath = File.read('pkg/classpath')
|
@@ -28,13 +28,13 @@ if RUBY_PLATFORM =~ /java/
|
|
28
28
|
end
|
29
29
|
else
|
30
30
|
require 'rake/extensiontask'
|
31
|
-
spec =
|
31
|
+
spec = Gem::Specification.load("psych.gemspec")
|
32
32
|
Rake::ExtensionTask.new("psych", spec) do |ext|
|
33
33
|
ext.lib_dir = File.join(*['lib', ENV['FAT_DIR']].compact)
|
34
34
|
ext.cross_compile = true
|
35
35
|
ext.cross_platform = %w[x86-mingw32 x64-mingw32]
|
36
36
|
ext.cross_compiling do |s|
|
37
|
-
s.files.concat ["lib/2.
|
37
|
+
s.files.concat ["lib/2.3/psych.so", "lib/2.4/psych.so", "lib/2.5/psych.so"]
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -42,7 +42,7 @@ end
|
|
42
42
|
desc "Compile binaries for mingw platform using rake-compiler-dock"
|
43
43
|
task 'build:mingw' do
|
44
44
|
require 'rake_compiler_dock'
|
45
|
-
RakeCompilerDock.sh "bundle && rake cross native gem RUBY_CC_VERSION=2.
|
45
|
+
RakeCompilerDock.sh "bundle && rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0"
|
46
46
|
end
|
47
47
|
|
48
48
|
task :default => [:compile, :test]
|
data/ext/psych/yaml/api.c
CHANGED
@@ -74,7 +74,7 @@ YAML_DECLARE(int)
|
|
74
74
|
yaml_string_extend(yaml_char_t **start,
|
75
75
|
yaml_char_t **pointer, yaml_char_t **end)
|
76
76
|
{
|
77
|
-
yaml_char_t *new_start = yaml_realloc(*start, (*end - *start)*2);
|
77
|
+
yaml_char_t *new_start = (yaml_char_t *)yaml_realloc((void*)*start, (*end - *start)*2);
|
78
78
|
|
79
79
|
if (!new_start) return 0;
|
80
80
|
|
@@ -94,8 +94,9 @@ yaml_string_extend(yaml_char_t **start,
|
|
94
94
|
YAML_DECLARE(int)
|
95
95
|
yaml_string_join(
|
96
96
|
yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
|
97
|
-
yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end)
|
97
|
+
yaml_char_t **b_start, yaml_char_t **b_pointer, SHIM(yaml_char_t **b_end))
|
98
98
|
{
|
99
|
+
UNUSED_PARAM(b_end)
|
99
100
|
if (*b_start == *b_pointer)
|
100
101
|
return 1;
|
101
102
|
|
@@ -177,17 +178,17 @@ yaml_parser_initialize(yaml_parser_t *parser)
|
|
177
178
|
goto error;
|
178
179
|
if (!BUFFER_INIT(parser, parser->buffer, INPUT_BUFFER_SIZE))
|
179
180
|
goto error;
|
180
|
-
if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE))
|
181
|
+
if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE, yaml_token_t*))
|
181
182
|
goto error;
|
182
|
-
if (!STACK_INIT(parser, parser->indents,
|
183
|
+
if (!STACK_INIT(parser, parser->indents, int*))
|
183
184
|
goto error;
|
184
|
-
if (!STACK_INIT(parser, parser->simple_keys,
|
185
|
+
if (!STACK_INIT(parser, parser->simple_keys, yaml_simple_key_t*))
|
185
186
|
goto error;
|
186
|
-
if (!STACK_INIT(parser, parser->states,
|
187
|
+
if (!STACK_INIT(parser, parser->states, yaml_parser_state_t*))
|
187
188
|
goto error;
|
188
|
-
if (!STACK_INIT(parser, parser->marks,
|
189
|
+
if (!STACK_INIT(parser, parser->marks, yaml_mark_t*))
|
189
190
|
goto error;
|
190
|
-
if (!STACK_INIT(parser, parser->tag_directives,
|
191
|
+
if (!STACK_INIT(parser, parser->tag_directives, yaml_tag_directive_t*))
|
191
192
|
goto error;
|
192
193
|
|
193
194
|
return 1;
|
@@ -243,7 +244,7 @@ static int
|
|
243
244
|
yaml_string_read_handler(void *data, unsigned char *buffer, size_t size,
|
244
245
|
size_t *size_read)
|
245
246
|
{
|
246
|
-
yaml_parser_t *parser = data;
|
247
|
+
yaml_parser_t *parser = (yaml_parser_t *)data;
|
247
248
|
|
248
249
|
if (parser->input.string.current == parser->input.string.end) {
|
249
250
|
*size_read = 0;
|
@@ -269,7 +270,7 @@ static int
|
|
269
270
|
yaml_file_read_handler(void *data, unsigned char *buffer, size_t size,
|
270
271
|
size_t *size_read)
|
271
272
|
{
|
272
|
-
yaml_parser_t *parser = data;
|
273
|
+
yaml_parser_t *parser = (yaml_parser_t *)data;
|
273
274
|
|
274
275
|
*size_read = fread(buffer, 1, size, parser->input.file);
|
275
276
|
return !ferror(parser->input.file);
|
@@ -355,13 +356,13 @@ yaml_emitter_initialize(yaml_emitter_t *emitter)
|
|
355
356
|
goto error;
|
356
357
|
if (!BUFFER_INIT(emitter, emitter->raw_buffer, OUTPUT_RAW_BUFFER_SIZE))
|
357
358
|
goto error;
|
358
|
-
if (!STACK_INIT(emitter, emitter->states,
|
359
|
+
if (!STACK_INIT(emitter, emitter->states, yaml_emitter_state_t*))
|
359
360
|
goto error;
|
360
|
-
if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE))
|
361
|
+
if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE, yaml_event_t*))
|
361
362
|
goto error;
|
362
|
-
if (!STACK_INIT(emitter, emitter->indents,
|
363
|
+
if (!STACK_INIT(emitter, emitter->indents, int*))
|
363
364
|
goto error;
|
364
|
-
if (!STACK_INIT(emitter, emitter->tag_directives,
|
365
|
+
if (!STACK_INIT(emitter, emitter->tag_directives, yaml_tag_directive_t*))
|
365
366
|
goto error;
|
366
367
|
|
367
368
|
return 1;
|
@@ -413,7 +414,7 @@ yaml_emitter_delete(yaml_emitter_t *emitter)
|
|
413
414
|
static int
|
414
415
|
yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
|
415
416
|
{
|
416
|
-
|
417
|
+
yaml_emitter_t *emitter = (yaml_emitter_t *)data;
|
417
418
|
|
418
419
|
if (emitter->output.string.size - *emitter->output.string.size_written
|
419
420
|
< size) {
|
@@ -439,7 +440,7 @@ yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
|
|
439
440
|
static int
|
440
441
|
yaml_file_write_handler(void *data, unsigned char *buffer, size_t size)
|
441
442
|
{
|
442
|
-
yaml_emitter_t *emitter = data;
|
443
|
+
yaml_emitter_t *emitter = (yaml_emitter_t *)data;
|
443
444
|
|
444
445
|
return (fwrite(buffer, 1, size, emitter->output.file) == size);
|
445
446
|
}
|
@@ -717,7 +718,7 @@ yaml_document_start_event_initialize(yaml_event_t *event,
|
|
717
718
|
/* Valid tag directives are expected. */
|
718
719
|
|
719
720
|
if (version_directive) {
|
720
|
-
version_directive_copy =
|
721
|
+
version_directive_copy = YAML_MALLOC_STATIC(yaml_version_directive_t);
|
721
722
|
if (!version_directive_copy) goto error;
|
722
723
|
version_directive_copy->major = version_directive->major;
|
723
724
|
version_directive_copy->minor = version_directive->minor;
|
@@ -725,7 +726,7 @@ yaml_document_start_event_initialize(yaml_event_t *event,
|
|
725
726
|
|
726
727
|
if (tag_directives_start != tag_directives_end) {
|
727
728
|
yaml_tag_directive_t *tag_directive;
|
728
|
-
if (!STACK_INIT(&context, tag_directives_copy,
|
729
|
+
if (!STACK_INIT(&context, tag_directives_copy, yaml_tag_directive_t*))
|
729
730
|
goto error;
|
730
731
|
for (tag_directive = tag_directives_start;
|
731
732
|
tag_directive != tag_directives_end; tag_directive ++) {
|
@@ -843,7 +844,7 @@ yaml_scalar_event_initialize(yaml_event_t *event,
|
|
843
844
|
}
|
844
845
|
|
845
846
|
if (!yaml_check_utf8(value, length)) goto error;
|
846
|
-
value_copy =
|
847
|
+
value_copy = YAML_MALLOC(length+1);
|
847
848
|
if (!value_copy) goto error;
|
848
849
|
memcpy(value_copy, value, length);
|
849
850
|
value_copy[length] = '\0';
|
@@ -1055,10 +1056,10 @@ yaml_document_initialize(yaml_document_t *document,
|
|
1055
1056
|
(tag_directives_start == tag_directives_end));
|
1056
1057
|
/* Valid tag directives are expected. */
|
1057
1058
|
|
1058
|
-
if (!STACK_INIT(&context, nodes,
|
1059
|
+
if (!STACK_INIT(&context, nodes, yaml_node_t*)) goto error;
|
1059
1060
|
|
1060
1061
|
if (version_directive) {
|
1061
|
-
version_directive_copy =
|
1062
|
+
version_directive_copy = YAML_MALLOC_STATIC(yaml_version_directive_t);
|
1062
1063
|
if (!version_directive_copy) goto error;
|
1063
1064
|
version_directive_copy->major = version_directive->major;
|
1064
1065
|
version_directive_copy->minor = version_directive->minor;
|
@@ -1066,7 +1067,7 @@ yaml_document_initialize(yaml_document_t *document,
|
|
1066
1067
|
|
1067
1068
|
if (tag_directives_start != tag_directives_end) {
|
1068
1069
|
yaml_tag_directive_t *tag_directive;
|
1069
|
-
if (!STACK_INIT(&context, tag_directives_copy,
|
1070
|
+
if (!STACK_INIT(&context, tag_directives_copy, yaml_tag_directive_t*))
|
1070
1071
|
goto error;
|
1071
1072
|
for (tag_directive = tag_directives_start;
|
1072
1073
|
tag_directive != tag_directives_end; tag_directive ++) {
|
@@ -1219,7 +1220,7 @@ yaml_document_add_scalar(yaml_document_t *document,
|
|
1219
1220
|
}
|
1220
1221
|
|
1221
1222
|
if (!yaml_check_utf8(value, length)) goto error;
|
1222
|
-
value_copy =
|
1223
|
+
value_copy = YAML_MALLOC(length+1);
|
1223
1224
|
if (!value_copy) goto error;
|
1224
1225
|
memcpy(value_copy, value, length);
|
1225
1226
|
value_copy[length] = '\0';
|
@@ -1266,7 +1267,7 @@ yaml_document_add_sequence(yaml_document_t *document,
|
|
1266
1267
|
tag_copy = yaml_strdup(tag);
|
1267
1268
|
if (!tag_copy) goto error;
|
1268
1269
|
|
1269
|
-
if (!STACK_INIT(&context, items,
|
1270
|
+
if (!STACK_INIT(&context, items, yaml_node_item_t*)) goto error;
|
1270
1271
|
|
1271
1272
|
SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,
|
1272
1273
|
style, mark, mark);
|
@@ -1311,7 +1312,7 @@ yaml_document_add_mapping(yaml_document_t *document,
|
|
1311
1312
|
tag_copy = yaml_strdup(tag);
|
1312
1313
|
if (!tag_copy) goto error;
|
1313
1314
|
|
1314
|
-
if (!STACK_INIT(&context, pairs,
|
1315
|
+
if (!STACK_INIT(&context, pairs, yaml_node_pair_t*)) goto error;
|
1315
1316
|
|
1316
1317
|
MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,
|
1317
1318
|
style, mark, mark);
|
data/ext/psych/yaml/config.h
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#define PACKAGE_NAME "yaml"
|
2
2
|
#define PACKAGE_TARNAME "yaml"
|
3
|
-
#define PACKAGE_VERSION "0.1
|
4
|
-
#define PACKAGE_STRING "yaml 0.1
|
3
|
+
#define PACKAGE_VERSION "0.2.1"
|
4
|
+
#define PACKAGE_STRING "yaml 0.2.1"
|
5
5
|
#define PACKAGE_BUGREPORT "https://github.com/yaml/libyaml/issues"
|
6
6
|
#define PACKAGE_URL "https://github.com/yaml/libyaml"
|
7
7
|
#define YAML_VERSION_MAJOR 0
|
8
|
-
#define YAML_VERSION_MINOR
|
9
|
-
#define YAML_VERSION_PATCH
|
10
|
-
#define YAML_VERSION_STRING "0.1
|
8
|
+
#define YAML_VERSION_MINOR 2
|
9
|
+
#define YAML_VERSION_PATCH 1
|
10
|
+
#define YAML_VERSION_STRING "0.2.1"
|
data/ext/psych/yaml/dumper.c
CHANGED
@@ -245,9 +245,9 @@ yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index)
|
|
245
245
|
#define ANCHOR_TEMPLATE_LENGTH 16
|
246
246
|
|
247
247
|
static yaml_char_t *
|
248
|
-
yaml_emitter_generate_anchor(yaml_emitter_t *emitter, int anchor_id)
|
248
|
+
yaml_emitter_generate_anchor(SHIM(yaml_emitter_t *emitter), int anchor_id)
|
249
249
|
{
|
250
|
-
yaml_char_t *anchor =
|
250
|
+
yaml_char_t *anchor = YAML_MALLOC(ANCHOR_TEMPLATE_LENGTH);
|
251
251
|
|
252
252
|
if (!anchor) return NULL;
|
253
253
|
|
data/ext/psych/yaml/emitter.c
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
*/
|
25
25
|
|
26
26
|
#define PUT_BREAK(emitter) \
|
27
|
-
(FLUSH(emitter) ?
|
27
|
+
(FLUSH(emitter) ? \
|
28
28
|
((emitter->line_break == YAML_CR_BREAK ? \
|
29
29
|
(*(emitter->buffer.pointer++) = (yaml_char_t) '\r') : \
|
30
30
|
emitter->line_break == YAML_LN_BREAK ? \
|
@@ -1002,7 +1002,7 @@ yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
|
|
1002
1002
|
*/
|
1003
1003
|
|
1004
1004
|
static int
|
1005
|
-
yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_event_t *event)
|
1005
|
+
yaml_emitter_emit_alias(yaml_emitter_t *emitter, SHIM(yaml_event_t *event))
|
1006
1006
|
{
|
1007
1007
|
if (!yaml_emitter_process_anchor(emitter))
|
1008
1008
|
return 0;
|
@@ -1087,7 +1087,7 @@ yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event)
|
|
1087
1087
|
*/
|
1088
1088
|
|
1089
1089
|
static int
|
1090
|
-
yaml_emitter_check_empty_document(yaml_emitter_t *emitter)
|
1090
|
+
yaml_emitter_check_empty_document(SHIM(yaml_emitter_t *emitter))
|
1091
1091
|
{
|
1092
1092
|
return 0;
|
1093
1093
|
}
|
@@ -1234,7 +1234,7 @@ yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event)
|
|
1234
1234
|
}
|
1235
1235
|
|
1236
1236
|
/*
|
1237
|
-
* Write an
|
1237
|
+
* Write an anchor.
|
1238
1238
|
*/
|
1239
1239
|
|
1240
1240
|
static int
|
@@ -1946,10 +1946,6 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
|
|
1946
1946
|
|
1947
1947
|
emitter->whitespace = 0;
|
1948
1948
|
emitter->indention = 0;
|
1949
|
-
if (emitter->root_context)
|
1950
|
-
{
|
1951
|
-
emitter->open_ended = 1;
|
1952
|
-
}
|
1953
1949
|
|
1954
1950
|
return 1;
|
1955
1951
|
}
|
@@ -2326,4 +2322,3 @@ yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
|
|
2326
2322
|
|
2327
2323
|
return 1;
|
2328
2324
|
}
|
2329
|
-
|
data/ext/psych/yaml/loader.c
CHANGED
@@ -72,7 +72,7 @@ yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document)
|
|
72
72
|
assert(document); /* Non-NULL document object is expected. */
|
73
73
|
|
74
74
|
memset(document, 0, sizeof(yaml_document_t));
|
75
|
-
if (!STACK_INIT(parser, document->nodes,
|
75
|
+
if (!STACK_INIT(parser, document->nodes, yaml_node_t*))
|
76
76
|
goto error;
|
77
77
|
|
78
78
|
if (!parser->stream_start_produced) {
|
@@ -90,7 +90,7 @@ yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document)
|
|
90
90
|
return 1;
|
91
91
|
}
|
92
92
|
|
93
|
-
if (!STACK_INIT(parser, parser->aliases,
|
93
|
+
if (!STACK_INIT(parser, parser->aliases, yaml_alias_data_t*))
|
94
94
|
goto error;
|
95
95
|
|
96
96
|
parser->document = document;
|
@@ -339,7 +339,7 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
339
339
|
if (!tag) goto error;
|
340
340
|
}
|
341
341
|
|
342
|
-
if (!STACK_INIT(parser, items,
|
342
|
+
if (!STACK_INIT(parser, items, yaml_node_item_t*)) goto error;
|
343
343
|
|
344
344
|
SEQUENCE_NODE_INIT(node, tag, items.start, items.end,
|
345
345
|
first_event->data.sequence_start.style,
|
@@ -402,7 +402,7 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
402
402
|
if (!tag) goto error;
|
403
403
|
}
|
404
404
|
|
405
|
-
if (!STACK_INIT(parser, pairs,
|
405
|
+
if (!STACK_INIT(parser, pairs, yaml_node_pair_t*)) goto error;
|
406
406
|
|
407
407
|
MAPPING_NODE_INIT(node, tag, pairs.start, pairs.end,
|
408
408
|
first_event->data.mapping_start.style,
|
data/ext/psych/yaml/parser.c
CHANGED
@@ -605,7 +605,7 @@ yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
|
|
605
605
|
if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) {
|
606
606
|
size_t prefix_len = strlen((char *)tag_directive->prefix);
|
607
607
|
size_t suffix_len = strlen((char *)tag_suffix);
|
608
|
-
tag =
|
608
|
+
tag = YAML_MALLOC(prefix_len+suffix_len+1);
|
609
609
|
if (!tag) {
|
610
610
|
parser->error = YAML_MEMORY_ERROR;
|
611
611
|
goto error;
|
@@ -685,7 +685,7 @@ yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
|
|
685
685
|
return 1;
|
686
686
|
}
|
687
687
|
else if (anchor || tag) {
|
688
|
-
yaml_char_t *value =
|
688
|
+
yaml_char_t *value = YAML_MALLOC(1);
|
689
689
|
if (!value) {
|
690
690
|
parser->error = YAML_MEMORY_ERROR;
|
691
691
|
goto error;
|
@@ -1208,7 +1208,7 @@ yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event,
|
|
1208
1208
|
{
|
1209
1209
|
yaml_char_t *value;
|
1210
1210
|
|
1211
|
-
value =
|
1211
|
+
value = YAML_MALLOC(1);
|
1212
1212
|
if (!value) {
|
1213
1213
|
parser->error = YAML_MEMORY_ERROR;
|
1214
1214
|
return 0;
|
@@ -1245,7 +1245,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|
1245
1245
|
} tag_directives = { NULL, NULL, NULL };
|
1246
1246
|
yaml_token_t *token;
|
1247
1247
|
|
1248
|
-
if (!STACK_INIT(parser, tag_directives,
|
1248
|
+
if (!STACK_INIT(parser, tag_directives, yaml_tag_directive_t*))
|
1249
1249
|
goto error;
|
1250
1250
|
|
1251
1251
|
token = PEEK_TOKEN(parser);
|
@@ -1266,7 +1266,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|
1266
1266
|
"found incompatible YAML document", token->start_mark);
|
1267
1267
|
goto error;
|
1268
1268
|
}
|
1269
|
-
version_directive =
|
1269
|
+
version_directive = YAML_MALLOC_STATIC(yaml_version_directive_t);
|
1270
1270
|
if (!version_directive) {
|
1271
1271
|
parser->error = YAML_MEMORY_ERROR;
|
1272
1272
|
goto error;
|
data/ext/psych/yaml/reader.c
CHANGED
@@ -460,10 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
|
460
460
|
|
461
461
|
}
|
462
462
|
|
463
|
-
if (parser->offset >=
|
463
|
+
if (parser->offset >= MAX_FILE_SIZE) {
|
464
464
|
return yaml_parser_set_reader_error(parser, "input is too long",
|
465
|
-
|
465
|
+
parser->offset, -1);
|
466
|
+
}
|
466
467
|
|
467
468
|
return 1;
|
468
469
|
}
|
469
|
-
|
data/ext/psych/yaml/scanner.c
CHANGED
@@ -1188,7 +1188,7 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
|
|
1188
1188
|
{
|
1189
1189
|
if (parser->flow_level) {
|
1190
1190
|
parser->flow_level --;
|
1191
|
-
|
1191
|
+
(void)POP(parser, parser->simple_keys);
|
1192
1192
|
}
|
1193
1193
|
|
1194
1194
|
return 1;
|
@@ -2399,7 +2399,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
|
|
2399
2399
|
{
|
2400
2400
|
/* Set the handle to '' */
|
2401
2401
|
|
2402
|
-
handle =
|
2402
|
+
handle = YAML_MALLOC(1);
|
2403
2403
|
if (!handle) goto error;
|
2404
2404
|
handle[0] = '\0';
|
2405
2405
|
|
@@ -2451,7 +2451,7 @@ yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
|
|
2451
2451
|
/* Set the handle to '!'. */
|
2452
2452
|
|
2453
2453
|
yaml_free(handle);
|
2454
|
-
handle =
|
2454
|
+
handle = YAML_MALLOC(2);
|
2455
2455
|
if (!handle) goto error;
|
2456
2456
|
handle[0] = '!';
|
2457
2457
|
handle[1] = '\0';
|
@@ -3160,8 +3160,8 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
3160
3160
|
*(string.pointer++) = '"';
|
3161
3161
|
break;
|
3162
3162
|
|
3163
|
-
case '
|
3164
|
-
*(string.pointer++) = '
|
3163
|
+
case '/':
|
3164
|
+
*(string.pointer++) = '/';
|
3165
3165
|
break;
|
3166
3166
|
|
3167
3167
|
case '\\':
|
@@ -3278,6 +3278,11 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
3278
3278
|
|
3279
3279
|
/* Check if we are at the end of the scalar. */
|
3280
3280
|
|
3281
|
+
/* Fix for crash unitialized value crash
|
3282
|
+
* Credit for the bug and input is to OSS Fuzz
|
3283
|
+
* Credit for the fix to Alex Gaynor
|
3284
|
+
*/
|
3285
|
+
if (!CACHE(parser, 1)) goto error;
|
3281
3286
|
if (CHECK(parser->buffer, single ? '\'' : '"'))
|
3282
3287
|
break;
|
3283
3288
|
|
@@ -3507,7 +3512,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
3507
3512
|
if (leading_blanks && (int)parser->mark.column < indent
|
3508
3513
|
&& IS_TAB(parser->buffer)) {
|
3509
3514
|
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
|
3510
|
-
start_mark, "found a tab character that
|
3515
|
+
start_mark, "found a tab character that violate indentation");
|
3511
3516
|
goto error;
|
3512
3517
|
}
|
3513
3518
|
|
@@ -3571,4 +3576,3 @@ error:
|
|
3571
3576
|
|
3572
3577
|
return 0;
|
3573
3578
|
}
|
3574
|
-
|
@@ -12,16 +12,6 @@
|
|
12
12
|
#include <limits.h>
|
13
13
|
#include <stddef.h>
|
14
14
|
|
15
|
-
#ifndef _MSC_VER
|
16
|
-
#include <stdint.h>
|
17
|
-
#else
|
18
|
-
#ifdef _WIN64
|
19
|
-
#define PTRDIFF_MAX _I64_MAX
|
20
|
-
#else
|
21
|
-
#define PTRDIFF_MAX INT_MAX
|
22
|
-
#endif
|
23
|
-
#endif
|
24
|
-
|
25
15
|
/*
|
26
16
|
* Memory management.
|
27
17
|
*/
|
@@ -80,6 +70,17 @@ yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
|
|
80
70
|
|
81
71
|
#define OUTPUT_RAW_BUFFER_SIZE (OUTPUT_BUFFER_SIZE*2+2)
|
82
72
|
|
73
|
+
/*
|
74
|
+
* The maximum size of a YAML input file.
|
75
|
+
* This used to be PTRDIFF_MAX, but that's not entirely portable
|
76
|
+
* because stdint.h isn't available on all platforms.
|
77
|
+
* It is not entirely clear why this isn't the maximum value
|
78
|
+
* that can fit into the parser->offset field.
|
79
|
+
*/
|
80
|
+
|
81
|
+
#define MAX_FILE_SIZE (~(size_t)0 / 2)
|
82
|
+
|
83
|
+
|
83
84
|
/*
|
84
85
|
* The size of other stacks and queues.
|
85
86
|
*/
|
@@ -93,7 +94,7 @@ yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
|
|
93
94
|
*/
|
94
95
|
|
95
96
|
#define BUFFER_INIT(context,buffer,size) \
|
96
|
-
|
97
|
+
(((buffer).start = (yaml_char_t *)yaml_malloc(size)) ? \
|
97
98
|
((buffer).last = (buffer).pointer = (buffer).start, \
|
98
99
|
(buffer).end = (buffer).start+(size), \
|
99
100
|
1) : \
|
@@ -133,7 +134,7 @@ yaml_string_join(
|
|
133
134
|
(value).pointer = (string))
|
134
135
|
|
135
136
|
#define STRING_INIT(context,string,size) \
|
136
|
-
(((string).start =
|
137
|
+
(((string).start = YAML_MALLOC(size)) ? \
|
137
138
|
((string).pointer = (string).start, \
|
138
139
|
(string).end = (string).start+(size), \
|
139
140
|
memset((string).start, 0, (size)), \
|
@@ -423,10 +424,10 @@ yaml_stack_extend(void **start, void **top, void **end);
|
|
423
424
|
YAML_DECLARE(int)
|
424
425
|
yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
425
426
|
|
426
|
-
#define STACK_INIT(context,stack,
|
427
|
-
|
427
|
+
#define STACK_INIT(context,stack,type) \
|
428
|
+
(((stack).start = (type)yaml_malloc(INITIAL_STACK_SIZE*sizeof(*(stack).start))) ? \
|
428
429
|
((stack).top = (stack).start, \
|
429
|
-
(stack).end = (stack).start+
|
430
|
+
(stack).end = (stack).start+INITIAL_STACK_SIZE, \
|
430
431
|
1) : \
|
431
432
|
((context)->error = YAML_MEMORY_ERROR, \
|
432
433
|
0))
|
@@ -456,8 +457,8 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
|
456
457
|
#define POP(context,stack) \
|
457
458
|
(*(--(stack).top))
|
458
459
|
|
459
|
-
#define QUEUE_INIT(context,queue,size)
|
460
|
-
|
460
|
+
#define QUEUE_INIT(context,queue,size,type) \
|
461
|
+
(((queue).start = (type)yaml_malloc((size)*sizeof(*(queue).start))) ? \
|
461
462
|
((queue).head = (queue).tail = (queue).start, \
|
462
463
|
(queue).end = (queue).start+(size), \
|
463
464
|
1) : \
|
@@ -660,3 +661,28 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
|
660
661
|
(node).data.mapping.pairs.end = (node_pairs_end), \
|
661
662
|
(node).data.mapping.pairs.top = (node_pairs_start), \
|
662
663
|
(node).data.mapping.style = (node_style))
|
664
|
+
|
665
|
+
/* Strict C compiler warning helpers */
|
666
|
+
|
667
|
+
#if defined(__clang__) || defined(__GNUC__)
|
668
|
+
# define HASATTRIBUTE_UNUSED
|
669
|
+
#endif
|
670
|
+
#ifdef HASATTRIBUTE_UNUSED
|
671
|
+
# define __attribute__unused__ __attribute__((__unused__))
|
672
|
+
#else
|
673
|
+
# define __attribute__unused__
|
674
|
+
#endif
|
675
|
+
|
676
|
+
/* Shim arguments are arguments that must be included in your function,
|
677
|
+
* but serve no purpose inside. Silence compiler warnings. */
|
678
|
+
#define SHIM(a) /*@unused@*/ a __attribute__unused__
|
679
|
+
|
680
|
+
/* UNUSED_PARAM() marks a shim argument in the body to silence compiler warnings */
|
681
|
+
#ifdef __clang__
|
682
|
+
# define UNUSED_PARAM(a) (void)(a);
|
683
|
+
#else
|
684
|
+
# define UNUSED_PARAM(a) /*@-noeffect*/if (0) (void)(a)/*@=noeffect*/;
|
685
|
+
#endif
|
686
|
+
|
687
|
+
#define YAML_MALLOC_STATIC(type) (type*)yaml_malloc(sizeof(type))
|
688
|
+
#define YAML_MALLOC(size) (yaml_char_t *)yaml_malloc(size)
|
data/lib/psych.rb
CHANGED
@@ -36,7 +36,7 @@ require 'psych/class_loader'
|
|
36
36
|
# = Overview
|
37
37
|
#
|
38
38
|
# Psych is a YAML parser and emitter.
|
39
|
-
# Psych leverages libyaml [Home page:
|
39
|
+
# Psych leverages libyaml [Home page: https://pyyaml.org/wiki/LibYAML]
|
40
40
|
# or [HG repo: https://bitbucket.org/xi/libyaml] for its YAML parsing
|
41
41
|
# and emitting capabilities. In addition to wrapping libyaml, Psych also
|
42
42
|
# knows how to serialize and de-serialize most Ruby objects to and from
|
@@ -235,14 +235,16 @@ require 'psych/class_loader'
|
|
235
235
|
module Psych
|
236
236
|
# The version of libyaml Psych is using
|
237
237
|
LIBYAML_VERSION = Psych.libyaml_version.join '.'
|
238
|
-
|
239
|
-
|
238
|
+
# Deprecation guard
|
239
|
+
NOT_GIVEN = Object.new
|
240
|
+
private_constant :NOT_GIVEN
|
240
241
|
|
241
242
|
###
|
242
243
|
# Load +yaml+ in to a Ruby data structure. If multiple documents are
|
243
244
|
# provided, the object contained in the first document will be returned.
|
244
|
-
# +filename+ will be used in the exception message if any exception
|
245
|
-
# while parsing.
|
245
|
+
# +filename+ will be used in the exception message if any exception
|
246
|
+
# is raised while parsing. If +yaml+ is empty, it returns
|
247
|
+
# the specified +fallback+ return value, which defaults to +false+.
|
246
248
|
#
|
247
249
|
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
|
248
250
|
#
|
@@ -252,7 +254,7 @@ module Psych
|
|
252
254
|
# Psych.load("---\n - a\n - b") # => ['a', 'b']
|
253
255
|
#
|
254
256
|
# begin
|
255
|
-
# Psych.load("--- `", "file.txt")
|
257
|
+
# Psych.load("--- `", filename: "file.txt")
|
256
258
|
# rescue Psych::SyntaxError => ex
|
257
259
|
# ex.file # => 'file.txt'
|
258
260
|
# ex.message # => "(file.txt): found character that cannot start any token"
|
@@ -264,8 +266,16 @@ module Psych
|
|
264
266
|
# Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
|
265
267
|
# Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
266
268
|
#
|
267
|
-
|
268
|
-
|
269
|
+
# Raises a TypeError when `yaml` parameter is NilClass
|
270
|
+
#
|
271
|
+
def self.load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false
|
272
|
+
if legacy_filename != NOT_GIVEN
|
273
|
+
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load is deprecated. Use keyword argument like Psych.load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
274
|
+
filename = legacy_filename
|
275
|
+
end
|
276
|
+
|
277
|
+
result = parse(yaml, filename: filename)
|
278
|
+
return fallback unless result
|
269
279
|
result = result.to_ruby if result
|
270
280
|
symbolize_names!(result) if symbolize_names
|
271
281
|
result
|
@@ -284,27 +294,27 @@ module Psych
|
|
284
294
|
# * Hash
|
285
295
|
#
|
286
296
|
# Recursive data structures are not allowed by default. Arbitrary classes
|
287
|
-
# can be allowed by adding those classes to the +
|
297
|
+
# can be allowed by adding those classes to the +permitted_classes+ keyword argument. They are
|
288
298
|
# additive. For example, to allow Date deserialization:
|
289
299
|
#
|
290
|
-
# Psych.safe_load(yaml, [Date])
|
300
|
+
# Psych.safe_load(yaml, permitted_classes: [Date])
|
291
301
|
#
|
292
302
|
# Now the Date class can be loaded in addition to the classes listed above.
|
293
303
|
#
|
294
|
-
# Aliases can be explicitly allowed by changing the +aliases+
|
304
|
+
# Aliases can be explicitly allowed by changing the +aliases+ keyword argument.
|
295
305
|
# For example:
|
296
306
|
#
|
297
307
|
# x = []
|
298
308
|
# x << x
|
299
309
|
# yaml = Psych.dump x
|
300
310
|
# Psych.safe_load yaml # => raises an exception
|
301
|
-
# Psych.safe_load yaml,
|
311
|
+
# Psych.safe_load yaml, aliases: true # => loads the aliases
|
302
312
|
#
|
303
313
|
# A Psych::DisallowedClass exception will be raised if the yaml contains a
|
304
|
-
# class that isn't in the
|
314
|
+
# class that isn't in the +permitted_classes+ list.
|
305
315
|
#
|
306
316
|
# A Psych::BadAlias exception will be raised if the yaml contains aliases
|
307
|
-
# but the +aliases+
|
317
|
+
# but the +aliases+ keyword argument is set to false.
|
308
318
|
#
|
309
319
|
# +filename+ will be used in the exception message if any exception is raised
|
310
320
|
# while parsing.
|
@@ -315,18 +325,38 @@ module Psych
|
|
315
325
|
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
|
316
326
|
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
317
327
|
#
|
318
|
-
def self.safe_load yaml,
|
319
|
-
|
320
|
-
|
328
|
+
def self.safe_load yaml, legacy_permitted_classes = NOT_GIVEN, legacy_permitted_symbols = NOT_GIVEN, legacy_aliases = NOT_GIVEN, legacy_filename = NOT_GIVEN, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false
|
329
|
+
if legacy_permitted_classes != NOT_GIVEN
|
330
|
+
warn_with_uplevel 'Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead.', uplevel: 1 if $VERBOSE
|
331
|
+
permitted_classes = legacy_permitted_classes
|
332
|
+
end
|
321
333
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
334
|
+
if legacy_permitted_symbols != NOT_GIVEN
|
335
|
+
warn_with_uplevel 'Passing permitted_symbols with the 3rd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_symbols: ...) instead.', uplevel: 1 if $VERBOSE
|
336
|
+
permitted_symbols = legacy_permitted_symbols
|
337
|
+
end
|
338
|
+
|
339
|
+
if legacy_aliases != NOT_GIVEN
|
340
|
+
warn_with_uplevel 'Passing aliases with the 4th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, aliases: ...) instead.', uplevel: 1 if $VERBOSE
|
341
|
+
aliases = legacy_aliases
|
342
|
+
end
|
343
|
+
|
344
|
+
if legacy_filename != NOT_GIVEN
|
345
|
+
warn_with_uplevel 'Passing filename with the 5th argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
346
|
+
filename = legacy_filename
|
329
347
|
end
|
348
|
+
|
349
|
+
result = parse(yaml, filename: filename)
|
350
|
+
return fallback unless result
|
351
|
+
|
352
|
+
class_loader = ClassLoader::Restricted.new(permitted_classes.map(&:to_s),
|
353
|
+
permitted_symbols.map(&:to_s))
|
354
|
+
scanner = ScalarScanner.new class_loader
|
355
|
+
visitor = if aliases
|
356
|
+
Visitors::ToRuby.new scanner, class_loader
|
357
|
+
else
|
358
|
+
Visitors::NoAliasRuby.new scanner, class_loader
|
359
|
+
end
|
330
360
|
result = visitor.accept result
|
331
361
|
symbolize_names!(result) if symbolize_names
|
332
362
|
result
|
@@ -344,28 +374,40 @@ module Psych
|
|
344
374
|
# Psych.parse("---\n - a\n - b") # => #<Psych::Nodes::Document:0x00>
|
345
375
|
#
|
346
376
|
# begin
|
347
|
-
# Psych.parse("--- `", "file.txt")
|
377
|
+
# Psych.parse("--- `", filename: "file.txt")
|
348
378
|
# rescue Psych::SyntaxError => ex
|
349
379
|
# ex.file # => 'file.txt'
|
350
380
|
# ex.message # => "(file.txt): found character that cannot start any token"
|
351
381
|
# end
|
352
382
|
#
|
353
383
|
# See Psych::Nodes for more information about YAML AST.
|
354
|
-
def self.parse yaml,
|
355
|
-
|
384
|
+
def self.parse yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: NOT_GIVEN
|
385
|
+
if legacy_filename != NOT_GIVEN
|
386
|
+
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.parse is deprecated. Use keyword argument like Psych.parse(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
387
|
+
filename = legacy_filename
|
388
|
+
end
|
389
|
+
|
390
|
+
parse_stream(yaml, filename: filename) do |node|
|
356
391
|
return node
|
357
392
|
end
|
358
|
-
|
393
|
+
|
394
|
+
if fallback != NOT_GIVEN
|
395
|
+
warn_with_uplevel 'Passing the `fallback` keyword argument of Psych.parse is deprecated.', uplevel: 1 if $VERBOSE
|
396
|
+
fallback
|
397
|
+
else
|
398
|
+
false
|
399
|
+
end
|
359
400
|
end
|
360
401
|
|
361
402
|
###
|
362
403
|
# Parse a file at +filename+. Returns the Psych::Nodes::Document.
|
363
404
|
#
|
364
405
|
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
|
365
|
-
def self.parse_file filename
|
366
|
-
File.open filename, 'r:bom|utf-8' do |f|
|
367
|
-
parse f, filename
|
406
|
+
def self.parse_file filename, fallback: false
|
407
|
+
result = File.open filename, 'r:bom|utf-8' do |f|
|
408
|
+
parse f, filename: filename
|
368
409
|
end
|
410
|
+
result || fallback
|
369
411
|
end
|
370
412
|
|
371
413
|
###
|
@@ -394,14 +436,21 @@ module Psych
|
|
394
436
|
# end
|
395
437
|
#
|
396
438
|
# begin
|
397
|
-
# Psych.parse_stream("--- `", "file.txt")
|
439
|
+
# Psych.parse_stream("--- `", filename: "file.txt")
|
398
440
|
# rescue Psych::SyntaxError => ex
|
399
441
|
# ex.file # => 'file.txt'
|
400
442
|
# ex.message # => "(file.txt): found character that cannot start any token"
|
401
443
|
# end
|
402
444
|
#
|
445
|
+
# Raises a TypeError when NilClass is passed.
|
446
|
+
#
|
403
447
|
# See Psych::Nodes for more information about YAML AST.
|
404
|
-
def self.parse_stream yaml,
|
448
|
+
def self.parse_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, &block
|
449
|
+
if legacy_filename != NOT_GIVEN
|
450
|
+
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.parse_stream is deprecated. Use keyword argument like Psych.parse_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
451
|
+
filename = legacy_filename
|
452
|
+
end
|
453
|
+
|
405
454
|
if block_given?
|
406
455
|
parser = Psych::Parser.new(Handlers::DocumentStream.new(&block))
|
407
456
|
parser.parse yaml, filename
|
@@ -502,14 +551,22 @@ module Psych
|
|
502
551
|
# end
|
503
552
|
# list # => ['foo', 'bar']
|
504
553
|
#
|
505
|
-
def self.load_stream yaml,
|
506
|
-
if
|
507
|
-
|
508
|
-
|
509
|
-
end
|
510
|
-
else
|
511
|
-
parse_stream(yaml, filename).children.map { |child| child.to_ruby }
|
554
|
+
def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: []
|
555
|
+
if legacy_filename != NOT_GIVEN
|
556
|
+
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load_stream is deprecated. Use keyword argument like Psych.load_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
557
|
+
filename = legacy_filename
|
512
558
|
end
|
559
|
+
|
560
|
+
result = if block_given?
|
561
|
+
parse_stream(yaml, filename: filename) do |node|
|
562
|
+
yield node.to_ruby
|
563
|
+
end
|
564
|
+
else
|
565
|
+
parse_stream(yaml, filename: filename).children.map(&:to_ruby)
|
566
|
+
end
|
567
|
+
|
568
|
+
return fallback if result.is_a?(Array) && result.empty?
|
569
|
+
result
|
513
570
|
end
|
514
571
|
|
515
572
|
###
|
@@ -518,7 +575,7 @@ module Psych
|
|
518
575
|
# the specified +fallback+ return value, which defaults to +false+.
|
519
576
|
def self.load_file filename, fallback: false
|
520
577
|
File.open(filename, 'r:bom|utf-8') { |f|
|
521
|
-
self.load f, filename, fallback:
|
578
|
+
self.load f, filename: filename, fallback: fallback
|
522
579
|
}
|
523
580
|
end
|
524
581
|
|
@@ -560,6 +617,21 @@ module Psych
|
|
560
617
|
end
|
561
618
|
private_class_method :symbolize_names!
|
562
619
|
|
620
|
+
# Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
|
621
|
+
def self.warn_with_uplevel(message, uplevel: 1)
|
622
|
+
at = parse_caller(caller[uplevel]).join(':')
|
623
|
+
warn "#{at}: #{message}"
|
624
|
+
end
|
625
|
+
|
626
|
+
def self.parse_caller(at)
|
627
|
+
if /^(.+?):(\d+)(?::in `.*')?/ =~ at
|
628
|
+
file = $1
|
629
|
+
line = $2.to_i
|
630
|
+
[file, line]
|
631
|
+
end
|
632
|
+
end
|
633
|
+
private_class_method :warn_with_uplevel, :parse_caller
|
634
|
+
|
563
635
|
class << self
|
564
636
|
attr_accessor :load_tags
|
565
637
|
attr_accessor :dump_tags
|
data/lib/psych/handler.rb
CHANGED
@@ -105,7 +105,7 @@ module Psych
|
|
105
105
|
# - first element
|
106
106
|
# - *ponies
|
107
107
|
#
|
108
|
-
# &ponies is the
|
108
|
+
# &ponies is the anchor, *ponies is the alias. In this case, alias is
|
109
109
|
# called with "ponies".
|
110
110
|
def alias anchor
|
111
111
|
end
|
data/lib/psych/versions.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
|
1
2
|
# frozen_string_literal: true
|
2
3
|
module Psych
|
3
|
-
# The version
|
4
|
-
VERSION = '3.0
|
4
|
+
# The version of Psych you are using
|
5
|
+
VERSION = '3.1.0' unless defined?(::Psych::VERSION)
|
5
6
|
|
6
7
|
if RUBY_ENGINE == 'jruby'
|
7
8
|
DEFAULT_SNAKEYAML_VERSION = '1.23'.freeze
|
data/psych.gemspec
CHANGED
@@ -1,14 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
begin
|
5
|
+
require_relative 'lib/psych/versions'
|
6
|
+
rescue LoadError
|
7
|
+
# for Ruby core repository
|
8
|
+
require_relative 'versions'
|
9
|
+
end
|
10
|
+
|
4
11
|
Gem::Specification.new do |s|
|
5
12
|
s.name = "psych"
|
6
|
-
s.version =
|
13
|
+
s.version = Psych::VERSION
|
7
14
|
s.authors = ["Aaron Patterson", "SHIBATA Hiroshi", "Charles Oliver Nutter"]
|
8
15
|
s.email = ["aaron@tenderlovemaking.com", "hsbt@ruby-lang.org", "headius@headius.com"]
|
9
16
|
s.summary = "Psych is a YAML parser and emitter"
|
10
17
|
s.description = <<-DESCRIPTION
|
11
|
-
Psych is a YAML parser and emitter. Psych leverages libyaml[
|
18
|
+
Psych is a YAML parser and emitter. Psych leverages libyaml[https://pyyaml.org/wiki/LibYAML]
|
12
19
|
for its YAML parsing and emitting capabilities. In addition to wrapping libyaml,
|
13
20
|
Psych also knows how to serialize and de-serialize most Ruby objects to and from the YAML format.
|
14
21
|
DESCRIPTION
|
@@ -50,14 +57,19 @@ DESCRIPTION
|
|
50
57
|
if RUBY_ENGINE == 'jruby'
|
51
58
|
s.platform = 'java'
|
52
59
|
s.files.concat [
|
53
|
-
"ext/java/
|
54
|
-
"ext/java/
|
60
|
+
"ext/java/org/jruby/ext/psych/PsychEmitter.java",
|
61
|
+
"ext/java/org/jruby/ext/psych/PsychLibrary.java",
|
62
|
+
"ext/java/org/jruby/ext/psych/PsychParser.java",
|
63
|
+
"ext/java/org/jruby/ext/psych/PsychToRuby.java",
|
64
|
+
"ext/java/org/jruby/ext/psych/PsychYamlTree.java",
|
65
|
+
"lib/psych_jars.rb",
|
66
|
+
"lib/psych.jar"
|
55
67
|
]
|
56
|
-
s.requirements = "jar org.yaml:snakeyaml,
|
68
|
+
s.requirements = "jar org.yaml:snakeyaml, #{Psych::DEFAULT_SNAKEYAML_VERSION}"
|
57
69
|
s.add_dependency 'jar-dependencies', '>= 0.1.7'
|
58
70
|
s.add_development_dependency 'ruby-maven'
|
59
71
|
else
|
60
72
|
s.extensions = ["ext/psych/extconf.rb"]
|
61
|
-
s.add_development_dependency 'rake-compiler-dock', ">= 0.6.
|
73
|
+
s.add_development_dependency 'rake-compiler-dock', ">= 0.6.3"
|
62
74
|
end
|
63
75
|
end
|
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: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-12-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake-compiler
|
@@ -46,16 +46,16 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.6.
|
49
|
+
version: 0.6.3
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.6.
|
56
|
+
version: 0.6.3
|
57
57
|
description: |
|
58
|
-
Psych is a YAML parser and emitter. Psych leverages libyaml[
|
58
|
+
Psych is a YAML parser and emitter. Psych leverages libyaml[https://pyyaml.org/wiki/LibYAML]
|
59
59
|
for its YAML parsing and emitting capabilities. In addition to wrapping libyaml,
|
60
60
|
Psych also knows how to serialize and de-serialize most Ruby objects to and from the YAML format.
|
61
61
|
email:
|
@@ -101,9 +101,9 @@ files:
|
|
101
101
|
- ext/psych/yaml/writer.c
|
102
102
|
- ext/psych/yaml/yaml.h
|
103
103
|
- ext/psych/yaml/yaml_private.h
|
104
|
-
- lib/2.2/psych.so
|
105
104
|
- lib/2.3/psych.so
|
106
105
|
- lib/2.4/psych.so
|
106
|
+
- lib/2.5/psych.so
|
107
107
|
- lib/psych.rb
|
108
108
|
- lib/psych/class_loader.rb
|
109
109
|
- lib/psych/coder.rb
|
@@ -156,10 +156,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '2.
|
159
|
+
version: '2.3'
|
160
160
|
- - "<"
|
161
161
|
- !ruby/object:Gem::Version
|
162
|
-
version: '2.
|
162
|
+
version: '2.6'
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
165
|
- - ">="
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
169
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.7.3
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Psych is a YAML parser and emitter
|