psych 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +19 -0
- data/ext/psych/yaml/emitter.c +7 -7
- data/ext/psych/yaml/loader.c +12 -0
- data/ext/psych/yaml/parser.c +1 -1
- data/ext/psych/yaml/reader.c +7 -3
- data/ext/psych/yaml/scanner.c +41 -31
- data/ext/psych/yaml/writer.c +1 -1
- data/ext/psych/yaml/yaml_private.h +19 -5
- data/lib/psych.rb +4 -3
- data/lib/psych/nodes/sequence.rb +1 -1
- data/lib/psych/visitors/to_ruby.rb +3 -1
- data/lib/psych/visitors/yaml_tree.rb +1 -1
- data/test/psych/test_object_references.rb +4 -0
- data/test/psych/test_string.rb +4 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1a904cdbd6c9e16a3b3857c895342397510bc5a
|
4
|
+
data.tar.gz: b4c98d184e105fce013d938635273f8e96ec7ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a1e6b690f408452c7b0f997ec8dc2c0b904ce3741bed5c9c571c0991b656296a7033e291fe37024f4f068807cf2828fe464a9369955666a4bf73f2efe31c67d
|
7
|
+
data.tar.gz: de45125a31f1e676f80c25cf34be04bb27c0da721baa92a548fbda4154a52d8169722b832f3a656eee8b2fd66435bd2f24634e2542552ce99113658fe4251764
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
Wed Feb 5 04:16:41 2014 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
|
+
|
3
|
+
* ext/psych/yaml/emitter.c: merge libyaml 0.1.5
|
4
|
+
* ext/psych/yaml/loader.c: ditto
|
5
|
+
* ext/psych/yaml/parser.c: ditto
|
6
|
+
* ext/psych/yaml/reader.c: ditto
|
7
|
+
* ext/psych/yaml/scanner.c: ditto
|
8
|
+
* ext/psych/yaml/writer.c: ditto
|
9
|
+
* ext/psych/yaml/yaml_private.h: ditto
|
10
|
+
|
11
|
+
Thu Jan 9 09:55:20 2014 Aaron Patterson <aaron@tenderlovemaking.com>
|
12
|
+
|
13
|
+
* ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings with
|
14
|
+
quotes should not have changed. [ruby-core:59316] [Bug #9300]
|
15
|
+
|
16
|
+
* ext/psych/lib/psych.rb: fixed missing require.
|
17
|
+
|
18
|
+
* test/psych/test_string.rb: test
|
19
|
+
|
1
20
|
Wed Nov 27 06:40:18 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
21
|
|
3
22
|
* ext/psych/lib/psych/scalar_scanner.rb: fix support for negative
|
data/ext/psych/yaml/emitter.c
CHANGED
@@ -221,7 +221,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter);
|
|
221
221
|
|
222
222
|
static int
|
223
223
|
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
|
224
|
-
|
224
|
+
char *indicator, int need_whitespace,
|
225
225
|
int is_whitespace, int is_indention);
|
226
226
|
|
227
227
|
static int
|
@@ -517,7 +517,7 @@ yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
|
|
517
517
|
if (emitter->best_width < 0) {
|
518
518
|
emitter->best_width = INT_MAX;
|
519
519
|
}
|
520
|
-
|
520
|
+
|
521
521
|
if (!emitter->line_break) {
|
522
522
|
emitter->line_break = YAML_LN_BREAK;
|
523
523
|
}
|
@@ -607,7 +607,7 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
|
|
607
607
|
if (!yaml_emitter_write_indent(emitter))
|
608
608
|
return 0;
|
609
609
|
}
|
610
|
-
|
610
|
+
|
611
611
|
if (event->data.document_start.tag_directives.start
|
612
612
|
!= event->data.document_start.tag_directives.end) {
|
613
613
|
implicit = 0;
|
@@ -721,7 +721,7 @@ yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
|
|
721
721
|
}
|
722
722
|
|
723
723
|
/*
|
724
|
-
*
|
724
|
+
*
|
725
725
|
* Expect a flow item node.
|
726
726
|
*/
|
727
727
|
|
@@ -1402,7 +1402,7 @@ yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
|
|
1402
1402
|
{
|
1403
1403
|
size_t anchor_length;
|
1404
1404
|
yaml_string_t string;
|
1405
|
-
|
1405
|
+
|
1406
1406
|
anchor_length = strlen((char *)anchor);
|
1407
1407
|
STRING_ASSIGN(string, anchor, anchor_length);
|
1408
1408
|
|
@@ -1784,7 +1784,7 @@ yaml_emitter_write_indent(yaml_emitter_t *emitter)
|
|
1784
1784
|
|
1785
1785
|
static int
|
1786
1786
|
yaml_emitter_write_indicator(yaml_emitter_t *emitter,
|
1787
|
-
|
1787
|
+
char *indicator, int need_whitespace,
|
1788
1788
|
int is_whitespace, int is_indention)
|
1789
1789
|
{
|
1790
1790
|
size_t indicator_length;
|
@@ -2178,7 +2178,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
|
|
2178
2178
|
yaml_string_t string)
|
2179
2179
|
{
|
2180
2180
|
char indent_hint[2];
|
2181
|
-
|
2181
|
+
char *chomp_hint = NULL;
|
2182
2182
|
|
2183
2183
|
if (IS_SPACE(string) || IS_BREAK(string))
|
2184
2184
|
{
|
data/ext/psych/yaml/loader.c
CHANGED
@@ -286,6 +286,8 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
286
286
|
int index;
|
287
287
|
yaml_char_t *tag = first_event->data.scalar.tag;
|
288
288
|
|
289
|
+
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
|
290
|
+
|
289
291
|
if (!tag || strcmp((char *)tag, "!") == 0) {
|
290
292
|
yaml_free(tag);
|
291
293
|
tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG);
|
@@ -329,6 +331,8 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
329
331
|
int index, item_index;
|
330
332
|
yaml_char_t *tag = first_event->data.sequence_start.tag;
|
331
333
|
|
334
|
+
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
|
335
|
+
|
332
336
|
if (!tag || strcmp((char *)tag, "!") == 0) {
|
333
337
|
yaml_free(tag);
|
334
338
|
tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG);
|
@@ -351,6 +355,9 @@ yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
351
355
|
if (!yaml_parser_parse(parser, &event)) return 0;
|
352
356
|
|
353
357
|
while (event.type != YAML_SEQUENCE_END_EVENT) {
|
358
|
+
if (!STACK_LIMIT(parser,
|
359
|
+
parser->document->nodes.start[index-1].data.sequence.items,
|
360
|
+
INT_MAX-1)) return 0;
|
354
361
|
item_index = yaml_parser_load_node(parser, &event);
|
355
362
|
if (!item_index) return 0;
|
356
363
|
if (!PUSH(parser,
|
@@ -387,6 +394,8 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
387
394
|
yaml_node_pair_t pair;
|
388
395
|
yaml_char_t *tag = first_event->data.mapping_start.tag;
|
389
396
|
|
397
|
+
if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
|
398
|
+
|
390
399
|
if (!tag || strcmp((char *)tag, "!") == 0) {
|
391
400
|
yaml_free(tag);
|
392
401
|
tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG);
|
@@ -409,6 +418,9 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
|
|
409
418
|
if (!yaml_parser_parse(parser, &event)) return 0;
|
410
419
|
|
411
420
|
while (event.type != YAML_MAPPING_END_EVENT) {
|
421
|
+
if (!STACK_LIMIT(parser,
|
422
|
+
parser->document->nodes.start[index-1].data.mapping.pairs,
|
423
|
+
INT_MAX-1)) return 0;
|
412
424
|
pair.key = yaml_parser_load_node(parser, &event);
|
413
425
|
if (!pair.key) return 0;
|
414
426
|
if (!yaml_parser_parse(parser, &event)) return 0;
|
data/ext/psych/yaml/parser.c
CHANGED
@@ -1295,7 +1295,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
|
|
1295
1295
|
token = PEEK_TOKEN(parser);
|
1296
1296
|
if (!token) goto error;
|
1297
1297
|
}
|
1298
|
-
|
1298
|
+
|
1299
1299
|
for (default_tag_directive = default_tag_directives;
|
1300
1300
|
default_tag_directive->handle; default_tag_directive++) {
|
1301
1301
|
if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
|
data/ext/psych/yaml/reader.c
CHANGED
@@ -52,7 +52,7 @@ yaml_parser_determine_encoding(yaml_parser_t *parser)
|
|
52
52
|
{
|
53
53
|
/* Ensure that we had enough bytes in the raw buffer. */
|
54
54
|
|
55
|
-
while (!parser->eof
|
55
|
+
while (!parser->eof
|
56
56
|
&& parser->raw_buffer.last - parser->raw_buffer.pointer < 3) {
|
57
57
|
if (!yaml_parser_update_raw_buffer(parser)) {
|
58
58
|
return 0;
|
@@ -295,7 +295,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
|
295
295
|
parser->offset, value);
|
296
296
|
|
297
297
|
break;
|
298
|
-
|
298
|
+
|
299
299
|
case YAML_UTF16LE_ENCODING:
|
300
300
|
case YAML_UTF16BE_ENCODING:
|
301
301
|
|
@@ -318,7 +318,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
|
318
318
|
*
|
319
319
|
* The following formulas are used for decoding
|
320
320
|
* and encoding characters using surrogate pairs:
|
321
|
-
*
|
321
|
+
*
|
322
322
|
* U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF)
|
323
323
|
* U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF)
|
324
324
|
* W1 = 110110yyyyyyyyyy
|
@@ -460,6 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
|
|
460
460
|
|
461
461
|
}
|
462
462
|
|
463
|
+
if (parser->offset >= PTRDIFF_MAX)
|
464
|
+
return yaml_parser_set_reader_error(parser, "input is too long",
|
465
|
+
PTRDIFF_MAX, -1);
|
466
|
+
|
463
467
|
return 1;
|
464
468
|
}
|
465
469
|
|
data/ext/psych/yaml/scanner.c
CHANGED
@@ -70,7 +70,7 @@
|
|
70
70
|
* %TAG !yaml! tag:yaml.org,2002:
|
71
71
|
* ---
|
72
72
|
*
|
73
|
-
* The
|
73
|
+
* The corresponding sequence of tokens:
|
74
74
|
*
|
75
75
|
* STREAM-START(utf-8)
|
76
76
|
* VERSION-DIRECTIVE(1,1)
|
@@ -615,11 +615,11 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser);
|
|
615
615
|
*/
|
616
616
|
|
617
617
|
static int
|
618
|
-
yaml_parser_roll_indent(yaml_parser_t *parser,
|
619
|
-
|
618
|
+
yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
|
619
|
+
ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark);
|
620
620
|
|
621
621
|
static int
|
622
|
-
yaml_parser_unroll_indent(yaml_parser_t *parser,
|
622
|
+
yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column);
|
623
623
|
|
624
624
|
/*
|
625
625
|
* Token fetchers.
|
@@ -762,7 +762,7 @@ yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
|
|
762
762
|
}
|
763
763
|
|
764
764
|
/* Fetch the next token from the queue. */
|
765
|
-
|
765
|
+
|
766
766
|
*token = DEQUEUE(parser, parser->tokens);
|
767
767
|
parser->token_available = 0;
|
768
768
|
parser->tokens_parsed ++;
|
@@ -1103,7 +1103,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
|
|
1103
1103
|
*/
|
1104
1104
|
|
1105
1105
|
int required = (!parser->flow_level
|
1106
|
-
&& parser->indent == (
|
1106
|
+
&& parser->indent == (ptrdiff_t)parser->mark.column);
|
1107
1107
|
|
1108
1108
|
/*
|
1109
1109
|
* A simple key is required only when it is the first token in the current
|
@@ -1121,7 +1121,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
|
|
1121
1121
|
yaml_simple_key_t simple_key;
|
1122
1122
|
simple_key.possible = 1;
|
1123
1123
|
simple_key.required = required;
|
1124
|
-
simple_key.token_number =
|
1124
|
+
simple_key.token_number =
|
1125
1125
|
parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
|
1126
1126
|
simple_key.mark = parser->mark;
|
1127
1127
|
|
@@ -1176,6 +1176,11 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser)
|
|
1176
1176
|
|
1177
1177
|
/* Increase the flow level. */
|
1178
1178
|
|
1179
|
+
if (parser->flow_level == INT_MAX) {
|
1180
|
+
parser->error = YAML_MEMORY_ERROR;
|
1181
|
+
return 0;
|
1182
|
+
}
|
1183
|
+
|
1179
1184
|
parser->flow_level++;
|
1180
1185
|
|
1181
1186
|
return 1;
|
@@ -1202,12 +1207,12 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
|
|
1202
1207
|
* Push the current indentation level to the stack and set the new level
|
1203
1208
|
* the current column is greater than the indentation level. In this case,
|
1204
1209
|
* append or insert the specified token into the token queue.
|
1205
|
-
*
|
1210
|
+
*
|
1206
1211
|
*/
|
1207
1212
|
|
1208
1213
|
static int
|
1209
|
-
yaml_parser_roll_indent(yaml_parser_t *parser,
|
1210
|
-
|
1214
|
+
yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
|
1215
|
+
ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark)
|
1211
1216
|
{
|
1212
1217
|
yaml_token_t token;
|
1213
1218
|
|
@@ -1226,6 +1231,11 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column,
|
|
1226
1231
|
if (!PUSH(parser, parser->indents, parser->indent))
|
1227
1232
|
return 0;
|
1228
1233
|
|
1234
|
+
if (column > INT_MAX) {
|
1235
|
+
parser->error = YAML_MEMORY_ERROR;
|
1236
|
+
return 0;
|
1237
|
+
}
|
1238
|
+
|
1229
1239
|
parser->indent = column;
|
1230
1240
|
|
1231
1241
|
/* Create a token and insert it into the queue. */
|
@@ -1248,13 +1258,13 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column,
|
|
1248
1258
|
|
1249
1259
|
/*
|
1250
1260
|
* Pop indentation levels from the indents stack until the current level
|
1251
|
-
* becomes less or equal to the column. For each
|
1261
|
+
* becomes less or equal to the column. For each intendation level, append
|
1252
1262
|
* the BLOCK-END token.
|
1253
1263
|
*/
|
1254
1264
|
|
1255
1265
|
|
1256
1266
|
static int
|
1257
|
-
yaml_parser_unroll_indent(yaml_parser_t *parser,
|
1267
|
+
yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
|
1258
1268
|
{
|
1259
1269
|
yaml_token_t token;
|
1260
1270
|
|
@@ -1263,7 +1273,7 @@ yaml_parser_unroll_indent(yaml_parser_t *parser, int column)
|
|
1263
1273
|
if (parser->flow_level)
|
1264
1274
|
return 1;
|
1265
1275
|
|
1266
|
-
/* Loop through the
|
1276
|
+
/* Loop through the intendation levels in the stack. */
|
1267
1277
|
|
1268
1278
|
while (parser->indent > column)
|
1269
1279
|
{
|
@@ -1935,7 +1945,7 @@ yaml_parser_scan_to_next_token(yaml_parser_t *parser)
|
|
1935
1945
|
*
|
1936
1946
|
* - in the flow context;
|
1937
1947
|
* - in the block context, but not at the beginning of the line or
|
1938
|
-
* after '-', '?', or ':' (complex value).
|
1948
|
+
* after '-', '?', or ':' (complex value).
|
1939
1949
|
*/
|
1940
1950
|
|
1941
1951
|
if (!CACHE(parser, 1)) return 0;
|
@@ -2574,7 +2584,7 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
|
|
2574
2584
|
|
2575
2585
|
/* Resize the string to include the head. */
|
2576
2586
|
|
2577
|
-
while (string.end - string.start <=
|
2587
|
+
while ((size_t)(string.end - string.start) <= length) {
|
2578
2588
|
if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
|
2579
2589
|
parser->error = YAML_MEMORY_ERROR;
|
2580
2590
|
goto error;
|
@@ -2769,15 +2779,15 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
2769
2779
|
|
2770
2780
|
if (IS_DIGIT(parser->buffer))
|
2771
2781
|
{
|
2772
|
-
/* Check that the
|
2782
|
+
/* Check that the intendation is greater than 0. */
|
2773
2783
|
|
2774
2784
|
if (CHECK(parser->buffer, '0')) {
|
2775
2785
|
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
2776
|
-
start_mark, "found an
|
2786
|
+
start_mark, "found an intendation indicator equal to 0");
|
2777
2787
|
goto error;
|
2778
2788
|
}
|
2779
2789
|
|
2780
|
-
/* Get the
|
2790
|
+
/* Get the intendation level and eat the indicator. */
|
2781
2791
|
|
2782
2792
|
increment = AS_DIGIT(parser->buffer);
|
2783
2793
|
|
@@ -2791,7 +2801,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
2791
2801
|
{
|
2792
2802
|
if (CHECK(parser->buffer, '0')) {
|
2793
2803
|
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
2794
|
-
start_mark, "found an
|
2804
|
+
start_mark, "found an intendation indicator equal to 0");
|
2795
2805
|
goto error;
|
2796
2806
|
}
|
2797
2807
|
|
@@ -2841,7 +2851,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
2841
2851
|
|
2842
2852
|
end_mark = parser->mark;
|
2843
2853
|
|
2844
|
-
/* Set the
|
2854
|
+
/* Set the intendation level if it was specified. */
|
2845
2855
|
|
2846
2856
|
if (increment) {
|
2847
2857
|
indent = parser->indent >= 0 ? parser->indent+increment : increment;
|
@@ -2907,7 +2917,7 @@ yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
2907
2917
|
|
2908
2918
|
if (!READ_LINE(parser, leading_break)) goto error;
|
2909
2919
|
|
2910
|
-
/* Eat the following
|
2920
|
+
/* Eat the following intendation spaces and line breaks. */
|
2911
2921
|
|
2912
2922
|
if (!yaml_parser_scan_block_scalar_breaks(parser,
|
2913
2923
|
&indent, &trailing_breaks, start_mark, &end_mark)) goto error;
|
@@ -2942,8 +2952,8 @@ error:
|
|
2942
2952
|
}
|
2943
2953
|
|
2944
2954
|
/*
|
2945
|
-
* Scan
|
2946
|
-
*
|
2955
|
+
* Scan intendation spaces and line breaks for a block scalar. Determine the
|
2956
|
+
* intendation level if needed.
|
2947
2957
|
*/
|
2948
2958
|
|
2949
2959
|
static int
|
@@ -2955,11 +2965,11 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
|
|
2955
2965
|
|
2956
2966
|
*end_mark = parser->mark;
|
2957
2967
|
|
2958
|
-
/* Eat the
|
2968
|
+
/* Eat the intendation spaces and line breaks. */
|
2959
2969
|
|
2960
2970
|
while (1)
|
2961
2971
|
{
|
2962
|
-
/* Eat the
|
2972
|
+
/* Eat the intendation spaces. */
|
2963
2973
|
|
2964
2974
|
if (!CACHE(parser, 1)) return 0;
|
2965
2975
|
|
@@ -2972,12 +2982,12 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
|
|
2972
2982
|
if ((int)parser->mark.column > max_indent)
|
2973
2983
|
max_indent = (int)parser->mark.column;
|
2974
2984
|
|
2975
|
-
/* Check for a tab character messing the
|
2985
|
+
/* Check for a tab character messing the intendation. */
|
2976
2986
|
|
2977
2987
|
if ((!*indent || (int)parser->mark.column < *indent)
|
2978
2988
|
&& IS_TAB(parser->buffer)) {
|
2979
2989
|
return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
|
2980
|
-
start_mark, "found a tab character where an
|
2990
|
+
start_mark, "found a tab character where an intendation space is expected");
|
2981
2991
|
}
|
2982
2992
|
|
2983
2993
|
/* Have we found a non-empty line? */
|
@@ -3001,7 +3011,7 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
|
|
3001
3011
|
*indent = 1;
|
3002
3012
|
}
|
3003
3013
|
|
3004
|
-
return 1;
|
3014
|
+
return 1;
|
3005
3015
|
}
|
3006
3016
|
|
3007
3017
|
/*
|
@@ -3498,12 +3508,12 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
3498
3508
|
{
|
3499
3509
|
if (IS_BLANK(parser->buffer))
|
3500
3510
|
{
|
3501
|
-
/* Check for tab character that abuse
|
3511
|
+
/* Check for tab character that abuse intendation. */
|
3502
3512
|
|
3503
3513
|
if (leading_blanks && (int)parser->mark.column < indent
|
3504
3514
|
&& IS_TAB(parser->buffer)) {
|
3505
3515
|
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
|
3506
|
-
start_mark, "found a tab character that
|
3516
|
+
start_mark, "found a tab character that violate intendation");
|
3507
3517
|
goto error;
|
3508
3518
|
}
|
3509
3519
|
|
@@ -3536,7 +3546,7 @@ yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
|
|
3536
3546
|
if (!CACHE(parser, 1)) goto error;
|
3537
3547
|
}
|
3538
3548
|
|
3539
|
-
/* Check
|
3549
|
+
/* Check intendation level. */
|
3540
3550
|
|
3541
3551
|
if (!parser->flow_level && (int)parser->mark.column < indent)
|
3542
3552
|
break;
|
data/ext/psych/yaml/writer.c
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
#ifdef RUBY_EXTCONF_H
|
2
|
-
#include RUBY_EXTCONF_H
|
3
|
-
#endif
|
4
1
|
|
5
2
|
#if HAVE_CONFIG_H
|
6
3
|
#include <config.h>
|
@@ -10,6 +7,17 @@
|
|
10
7
|
|
11
8
|
#include <assert.h>
|
12
9
|
#include <limits.h>
|
10
|
+
#include <stddef.h>
|
11
|
+
|
12
|
+
#ifndef _MSC_VER
|
13
|
+
#include <stdint.h>
|
14
|
+
#else
|
15
|
+
#ifdef _WIN64
|
16
|
+
#define PTRDIFF_MAX _I64_MAX
|
17
|
+
#else
|
18
|
+
#define PTRDIFF_MAX INT_MAX
|
19
|
+
#endif
|
20
|
+
#endif
|
13
21
|
|
14
22
|
/*
|
15
23
|
* Memory management.
|
@@ -231,9 +239,9 @@ yaml_string_join(
|
|
231
239
|
(string).pointer[offset] <= (yaml_char_t) 'f') ? \
|
232
240
|
((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \
|
233
241
|
((string).pointer[offset] - (yaml_char_t) '0'))
|
234
|
-
|
242
|
+
|
235
243
|
#define AS_HEX(string) AS_HEX_AT((string),0)
|
236
|
-
|
244
|
+
|
237
245
|
/*
|
238
246
|
* Check if the character is ASCII.
|
239
247
|
*/
|
@@ -424,6 +432,12 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
|
|
424
432
|
#define STACK_EMPTY(context,stack) \
|
425
433
|
((stack).start == (stack).top)
|
426
434
|
|
435
|
+
#define STACK_LIMIT(context,stack,size) \
|
436
|
+
((stack).top - (stack).start < (size) ? \
|
437
|
+
1 : \
|
438
|
+
((context)->error = YAML_MEMORY_ERROR, \
|
439
|
+
0))
|
440
|
+
|
427
441
|
#define PUSH(context,stack,value) \
|
428
442
|
(((stack).top != (stack).end \
|
429
443
|
|| yaml_stack_extend((void **)&(stack).start, \
|
data/lib/psych.rb
CHANGED
@@ -14,6 +14,7 @@ require 'psych/stream'
|
|
14
14
|
require 'psych/json/tree_builder'
|
15
15
|
require 'psych/json/stream'
|
16
16
|
require 'psych/handlers/document_stream'
|
17
|
+
require 'psych/class_loader'
|
17
18
|
|
18
19
|
###
|
19
20
|
# = Overview
|
@@ -71,7 +72,7 @@ require 'psych/handlers/document_stream'
|
|
71
72
|
# ==== Exception handling
|
72
73
|
#
|
73
74
|
# begin
|
74
|
-
# # The second argument
|
75
|
+
# # The second argument changes only the exception contents
|
75
76
|
# Psych.parse("--- `", "file.txt")
|
76
77
|
# rescue Psych::SyntaxError => ex
|
77
78
|
# ex.file # => 'file.txt'
|
@@ -135,7 +136,7 @@ require 'psych/handlers/document_stream'
|
|
135
136
|
# ==== Exception handling
|
136
137
|
#
|
137
138
|
# begin
|
138
|
-
# # The second argument
|
139
|
+
# # The second argument changes only the exception contents
|
139
140
|
# Psych.parse("--- `", "file.txt")
|
140
141
|
# rescue Psych::SyntaxError => ex
|
141
142
|
# ex.file # => 'file.txt'
|
@@ -216,7 +217,7 @@ require 'psych/handlers/document_stream'
|
|
216
217
|
|
217
218
|
module Psych
|
218
219
|
# The version is Psych you're using
|
219
|
-
VERSION = '2.0.
|
220
|
+
VERSION = '2.0.3'
|
220
221
|
|
221
222
|
# The version of libyaml Psych is using
|
222
223
|
LIBYAML_VERSION = Psych.libyaml_version.join '.'
|
data/lib/psych/nodes/sequence.rb
CHANGED
@@ -181,9 +181,11 @@ module Psych
|
|
181
181
|
klass = class_loader.struct
|
182
182
|
members = o.children.map { |c| accept c }
|
183
183
|
h = Hash[*members]
|
184
|
-
klass.new(*h.map { |k,v|
|
184
|
+
s = klass.new(*h.map { |k,v|
|
185
185
|
class_loader.symbolize k
|
186
186
|
}).new(*h.map { |k,v| v })
|
187
|
+
register(o, s)
|
188
|
+
s
|
187
189
|
end
|
188
190
|
|
189
191
|
when /^!ruby\/object:?(.*)?$/
|
data/test/psych/test_string.rb
CHANGED
@@ -15,6 +15,10 @@ module Psych
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_no_doublequotes_with_special_characters
|
19
|
+
assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"')
|
20
|
+
end
|
21
|
+
|
18
22
|
def test_doublequotes_when_there_is_a_single
|
19
23
|
yaml = Psych.dump "@123'abc"
|
20
24
|
assert_match(/---\s*"/, yaml)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.8'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.8'
|
55
55
|
description: |-
|
56
56
|
Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
|
57
57
|
for its YAML parsing and emitting capabilities. In addition to wrapping
|
@@ -68,6 +68,7 @@ extra_rdoc_files:
|
|
68
68
|
- README.rdoc
|
69
69
|
files:
|
70
70
|
- ".autotest"
|
71
|
+
- ".gemtest"
|
71
72
|
- ".travis.yml"
|
72
73
|
- CHANGELOG.rdoc
|
73
74
|
- Manifest.txt
|
@@ -180,7 +181,6 @@ files:
|
|
180
181
|
- test/psych/visitors/test_emitter.rb
|
181
182
|
- test/psych/visitors/test_to_ruby.rb
|
182
183
|
- test/psych/visitors/test_yaml_tree.rb
|
183
|
-
- ".gemtest"
|
184
184
|
homepage: http://github.com/tenderlove/psych
|
185
185
|
licenses:
|
186
186
|
- MIT
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
205
|
rubyforge_project: psych
|
206
|
-
rubygems_version: 2.
|
206
|
+
rubygems_version: 2.2.1
|
207
207
|
signing_key:
|
208
208
|
specification_version: 4
|
209
209
|
summary: Psych is a YAML parser and emitter
|