psych-shopifork 2.0.0 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTEwODA4N2U4Yzc3YzU4OTc3ZTMwMDlkZjc4OWViN2YzNTkwODBhOA==
5
- data.tar.gz: !binary |-
6
- OTAzY2RlZDg3ZjZjMGNlODc0OWUyNjIyMjZjOGMxZTcyMGYxODZkYw==
2
+ SHA1:
3
+ metadata.gz: f31f836e3f35aa883bf728bbb4e88839af44f711
4
+ data.tar.gz: 6912dc11aa3b595d89a6d4e337edb43c504ffa51
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OTA0OGQzZmExOTE0ZjYwMTgzY2JlYzBkYTFhZjZjNWQyNmEwMThmODA4Y2Jk
10
- YTUzNTVhMTA3OWIyNjk1Y2IwYmU4MWU4YzAyMmI3ODU4MTFjODNkYTM4OTA3
11
- YjYzZTIwY2IwMzQxNGNmMTBjODEyNGZhZDUwNTRiYjQ3YTM4N2U=
12
- data.tar.gz: !binary |-
13
- NzBlYzk2NGNiNzI3YzdhNzM4YmZiMjk4MWMwYWViOTdlMjU1YmRmM2VjMjAz
14
- Y2U4NTIxZTRkMmEwYjBhMThmZGZlMjJiM2M5NzIyMzI5NTVmZGQ4OGFiOGMx
15
- Yjc1ZDgyN2IzMzYxOGZjYWY4ZDZkN2IyNjNiODA5Y2VhMmJmZDY=
6
+ metadata.gz: a6f86c78ac8cd9ead8898808f904a250128e88f1ee08b0e39138b6ceaffcba6bd824d9710443c47aa8580b26d65a0f928700ab4a4d23459aeb029f9453622f47
7
+ data.tar.gz: f09c4b87b4998c54efee4f56d24701312ecaf3d2e0ea4c342ad389db06b61a26bfe6645f449cc1e5d108b2c569c1fa98c440d49ed717b414007069eb8ff5756c
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,61 @@
1
+ Wed Feb 5 10:11:36 2014 Zachary Scott <e@zzak.io>
2
+
3
+ * ext/psych/yaml/config.h: bump libyaml to 0.1.5
4
+
5
+ Wed Feb 5 04:16:41 2014 Aaron Patterson <aaron@tenderlovemaking.com>
6
+
7
+ * ext/psych/yaml/emitter.c: merge libyaml 0.1.5
8
+ * ext/psych/yaml/loader.c: ditto
9
+ * ext/psych/yaml/parser.c: ditto
10
+ * ext/psych/yaml/reader.c: ditto
11
+ * ext/psych/yaml/scanner.c: ditto
12
+ * ext/psych/yaml/writer.c: ditto
13
+ * ext/psych/yaml/yaml_private.h: ditto
14
+
15
+ Thu Jan 9 09:55:20 2014 Aaron Patterson <aaron@tenderlovemaking.com>
16
+
17
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: dumping strings with
18
+ quotes should not have changed. [ruby-core:59316] [Bug #9300]
19
+
20
+ * ext/psych/lib/psych.rb: fixed missing require.
21
+
22
+ * test/psych/test_string.rb: test
23
+
24
+ Wed Nov 27 06:40:18 2013 Aaron Patterson <aaron@tenderlovemaking.com>
25
+
26
+ * ext/psych/lib/psych/scalar_scanner.rb: fix support for negative
27
+ years.
28
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: ditto
29
+ * test/psych/test_date_time.rb: test for change.
30
+ Fixes: https://github.com/tenderlove/psych/issues/168
31
+
32
+ Wed Nov 27 04:46:55 2013 Aaron Patterson <aaron@tenderlovemaking.com>
33
+
34
+ * ext/psych/lib/psych/scalar_scanner.rb: fix regexp for matching TIME
35
+ strings.
36
+ * test/psych/test_date_time.rb: test for change.
37
+ Fixes: https://github.com/tenderlove/psych/issues/171
38
+
39
+ Wed Nov 6 04:14:25 2013 Aaron Patterson <aaron@tenderlovemaking.com>
40
+
41
+ * ext/psych/lib/psych/visitors/to_ruby.rb: process merge keys before
42
+ reviving objects. Fixes GH psych #168
43
+ * test/psych/test_merge_keys.rb: test for change
44
+ https://github.com/tenderlove/psych/issues/168
45
+
46
+ Wed Oct 30 03:25:10 2013 Aaron Patterson <aaron@tenderlovemaking.com>
47
+
48
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: make less garbage when
49
+ testing if a string is binary.
50
+
51
+ Wed Oct 30 03:08:24 2013 Aaron Patterson <aaron@tenderlovemaking.com>
52
+
53
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: string subclasses should
54
+ not be considered to be binary. Fixes Psych / GH 166
55
+ https://github.com/tenderlove/psych/issues/166
56
+
57
+ * test/psych/test_string.rb: test for fix
58
+
1
59
  Fri Sep 20 23:44:07 2013 Zachary Scott <e@zzak.io>
2
60
 
3
61
  * ext/psych/yaml/yaml.h: [DOC] fix typo by @GreenGeorge [Fixes GH-161]
@@ -1,11 +1,11 @@
1
1
 
2
2
  #define PACKAGE_NAME "yaml"
3
3
  #define PACKAGE_TARNAME "yaml"
4
- #define PACKAGE_VERSION "0.1.4"
5
- #define PACKAGE_STRING "yaml 0.1.4"
4
+ #define PACKAGE_VERSION "0.1.5"
5
+ #define PACKAGE_STRING "yaml 0.1.5"
6
6
  #define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component libyaml"
7
7
  #define PACKAGE_URL ""
8
8
  #define YAML_VERSION_MAJOR 0
9
9
  #define YAML_VERSION_MINOR 1
10
- #define YAML_VERSION_PATCH 4
11
- #define YAML_VERSION_STRING "0.1.4"
10
+ #define YAML_VERSION_PATCH 5
11
+ #define YAML_VERSION_STRING "0.1.5"
@@ -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
- const char *indicator, int need_whitespace,
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
- const char *indicator, int need_whitespace,
1787
+ char *indicator, int need_whitespace,
1788
1788
  int is_whitespace, int is_indention)
1789
1789
  {
1790
1790
  size_t indicator_length;
@@ -2184,7 +2184,7 @@ yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
2184
2184
  yaml_string_t string)
2185
2185
  {
2186
2186
  char indent_hint[2];
2187
- const char *chomp_hint = NULL;
2187
+ char *chomp_hint = NULL;
2188
2188
 
2189
2189
  if (IS_SPACE(string) || IS_BREAK(string))
2190
2190
  {
@@ -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;
@@ -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,
@@ -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
 
@@ -70,7 +70,7 @@
70
70
  * %TAG !yaml! tag:yaml.org,2002:
71
71
  * ---
72
72
  *
73
- * The correspoding sequence of tokens:
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, int column,
619
- int number, yaml_token_type_t type, yaml_mark_t mark);
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, int column);
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 == (int)parser->mark.column);
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, int column,
1210
- int number, yaml_token_type_t type, yaml_mark_t mark)
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 indentation level, append
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, int column)
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 indentation levels in the stack. */
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 <= (int)length) {
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 indentation is greater than 0. */
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 indentation indicator equal to 0");
2786
+ start_mark, "found an intendation indicator equal to 0");
2777
2787
  goto error;
2778
2788
  }
2779
2789
 
2780
- /* Get the indentation level and eat the indicator. */
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 indentation indicator equal to 0");
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 indentation level if it was specified. */
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 indentation spaces and line breaks. */
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 indentation spaces and line breaks for a block scalar. Determine the
2946
- * indentation level if needed.
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 indentation spaces and line breaks. */
2968
+ /* Eat the intendation spaces and line breaks. */
2959
2969
 
2960
2970
  while (1)
2961
2971
  {
2962
- /* Eat the indentation spaces. */
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 indentation. */
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 indentation space is expected");
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 indentation. */
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 violates indentation");
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 indentation level. */
3549
+ /* Check intendation level. */
3540
3550
 
3541
3551
  if (!parser->flow_level && (int)parser->mark.column < indent)
3542
3552
  break;
@@ -74,7 +74,7 @@ yaml_emitter_flush(yaml_emitter_t *emitter)
74
74
  unsigned int value;
75
75
  size_t k;
76
76
 
77
- /*
77
+ /*
78
78
  * See the "reader.c" code for more details on UTF-8 encoding. Note
79
79
  * that we assume that the buffer contains a valid UTF-8 sequence.
80
80
  */
@@ -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 chnages only the exception contents
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 chnages only the exception contents
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.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 '.'
@@ -56,7 +56,7 @@ module Psych
56
56
  # Is this sequence started implicitly?
57
57
  attr_accessor :implicit
58
58
 
59
- # The sequece style used
59
+ # The sequence style used
60
60
  attr_accessor :style
61
61
 
62
62
  ###
@@ -5,7 +5,7 @@ module Psych
5
5
  # Scan scalars for built in types
6
6
  class ScalarScanner
7
7
  # Taken from http://yaml.org/type/timestamp.html
8
- TIME = /^\d{4}-\d{1,2}-\d{1,2}([Tt]|\s+)\d{1,2}:\d\d:\d\d(\.\d*)?(\s*Z|[-+]\d{1,2}(:\d\d)?)?/
8
+ TIME = /^-?\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/
9
9
 
10
10
  # Taken from http://yaml.org/type/float.html
11
11
  FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10)
@@ -123,7 +123,7 @@ module Psych
123
123
  klass = class_loader.load 'Time'
124
124
 
125
125
  date, time = *(string.split(/[ tT]/, 2))
126
- (yy, m, dd) = date.split('-').map { |x| x.to_i }
126
+ (yy, m, dd) = date.match(/^(-?\d{4})-(\d{1,2})-(\d{1,2})/).captures.map { |x| x.to_i }
127
127
  md = time.match(/(\d+:\d+:\d+)(?:\.(\d*))?\s*(Z|[-+]\d+(:\d\d)?)?/)
128
128
 
129
129
  (hh, mm, ss) = md[1].split(':').map { |x| x.to_i }
@@ -156,7 +156,7 @@ module Psych
156
156
  if Psych.load_tags[o.tag]
157
157
  return revive(resolve_class(Psych.load_tags[o.tag]), o)
158
158
  end
159
- return revive_hash({}, o) unless o.tag
159
+ return revive_hash(register(o, {}), o) unless o.tag
160
160
 
161
161
  case o.tag
162
162
  when /^!ruby\/struct:?(.*)?$/
@@ -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:?(.*)?$/
@@ -256,7 +258,7 @@ module Psych
256
258
  set
257
259
 
258
260
  when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/
259
- revive_hash resolve_class($1).new, o
261
+ revive_hash register(o, resolve_class($1).new), o
260
262
 
261
263
  when '!omap', 'tag:yaml.org,2002:omap'
262
264
  map = register(o, class_loader.psych_omap.new)
@@ -266,7 +268,7 @@ module Psych
266
268
  map
267
269
 
268
270
  else
269
- revive_hash({}, o)
271
+ revive_hash(register(o, {}), o)
270
272
  end
271
273
  end
272
274
 
@@ -295,8 +297,6 @@ module Psych
295
297
  end
296
298
 
297
299
  def revive_hash hash, o
298
- @st[o.anchor] = hash if o.anchor
299
-
300
300
  o.children.each_slice(2) { |k,v|
301
301
  key = accept(k)
302
302
  val = accept(v)
@@ -334,10 +334,8 @@ module Psych
334
334
  end
335
335
 
336
336
  def revive klass, node
337
- s = klass.allocate
338
- @st[node.anchor] = s if node.anchor
339
- h = Hash[*node.children.map { |c| accept c }]
340
- init_with(s, h, node)
337
+ s = register(node, klass.allocate)
338
+ init_with(s, revive_hash({}, node), node)
341
339
  end
342
340
 
343
341
  def init_with o, h, node
@@ -209,7 +209,11 @@ module Psych
209
209
  end
210
210
 
211
211
  def visit_DateTime o
212
- formatted = format_time o.to_time
212
+ formatted = if o.offset.zero?
213
+ o.strftime("%Y-%m-%d %H:%M:%S.%9N Z".freeze)
214
+ else
215
+ o.strftime("%Y-%m-%d %H:%M:%S.%9N %:z".freeze)
216
+ end
213
217
  tag = '!ruby/object:DateTime'
214
218
  register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY)
215
219
  end
@@ -264,14 +268,6 @@ module Psych
264
268
  @emitter.scalar o._dump, nil, '!ruby/object:BigDecimal', false, false, Nodes::Scalar::ANY
265
269
  end
266
270
 
267
- def binary? string
268
- (string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) ||
269
- string.index("\x00") ||
270
- string.count("\x00-\x7F", "^ -~\t\r\n").fdiv(string.length) > 0.3 ||
271
- string.class != String
272
- end
273
- private :binary?
274
-
275
271
  def visit_String o
276
272
  plain = true
277
273
  quote = true
@@ -288,7 +284,7 @@ module Psych
288
284
  quote = false
289
285
  elsif o =~ /\n/
290
286
  style = Nodes::Scalar::LITERAL
291
- elsif o =~ /^\W/
287
+ elsif o =~ /^\W[^"]*$/
292
288
  style = Nodes::Scalar::DOUBLE_QUOTED
293
289
  else
294
290
  unless String === @ss.tokenize(o)
@@ -301,6 +297,8 @@ module Psych
301
297
  if ivars.empty?
302
298
  unless o.class == ::String
303
299
  tag = "!ruby/string:#{o.class}"
300
+ plain = false
301
+ quote = false
304
302
  end
305
303
  @emitter.scalar str, nil, tag, plain, quote, style
306
304
  else
@@ -379,6 +377,17 @@ module Psych
379
377
  end
380
378
 
381
379
  private
380
+ # FIXME: Remove the index and count checks in Psych 3.0
381
+ NULL = "\x00"
382
+ BINARY_RANGE = "\x00-\x7F"
383
+ WS_RANGE = "^ -~\t\r\n"
384
+
385
+ def binary? string
386
+ (string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) ||
387
+ string.index(NULL) ||
388
+ string.count(BINARY_RANGE, WS_RANGE).fdiv(string.length) > 0.3
389
+ end
390
+
382
391
  def visit_array_subclass o
383
392
  tag = "!ruby/array:#{o.class}"
384
393
  if o.instance_variables.empty?
@@ -3,6 +3,19 @@ require 'date'
3
3
 
4
4
  module Psych
5
5
  class TestDateTime < TestCase
6
+ def test_negative_year
7
+ time = Time.utc -1, 12, 16
8
+ assert_cycle time
9
+ end
10
+
11
+ def test_new_datetime
12
+ assert_cycle DateTime.new
13
+ end
14
+
15
+ def test_invalid_date
16
+ assert_cycle "2013-10-31T10:40:07-000000000000033"
17
+ end
18
+
6
19
  def test_string_tag
7
20
  dt = DateTime.now
8
21
  yaml = Psych.dump dt
@@ -2,6 +2,24 @@ require_relative 'helper'
2
2
 
3
3
  module Psych
4
4
  class TestMergeKeys < TestCase
5
+ class Product
6
+ attr_reader :bar
7
+ end
8
+
9
+ def test_mergekey_with_object
10
+ s = <<-eoyml
11
+ foo: &foo
12
+ bar: 10
13
+ product:
14
+ !ruby/object:#{Product.name}
15
+ <<: *foo
16
+ eoyml
17
+ hash = Psych.load s
18
+ assert_equal({"bar" => 10}, hash["foo"])
19
+ product = hash["product"]
20
+ assert_equal 10, product.bar
21
+ end
22
+
5
23
  def test_merge_nil
6
24
  yaml = <<-eoyml
7
25
  defaults: &defaults
@@ -26,6 +26,10 @@ module Psych
26
26
  assert_reference_trip DateTime.now
27
27
  end
28
28
 
29
+ def test_struct_has_references
30
+ assert_reference_trip Struct.new(:foo).new(1)
31
+ end
32
+
29
33
  def assert_reference_trip obj
30
34
  yml = Psych.dump([obj, obj])
31
35
  assert_match(/\*-?\d+/, yml)
@@ -15,11 +15,20 @@ 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)
21
25
  end
22
26
 
27
+ def test_cycle_x
28
+ str = X.new 'abc'
29
+ assert_cycle str
30
+ end
31
+
23
32
  def test_dash_dot
24
33
  assert_cycle '-.'
25
34
  assert_cycle '+.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psych-shopifork
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.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: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: rake-compiler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.4.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.4.1
41
41
  - !ruby/object:Gem::Dependency
@@ -44,21 +44,19 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '3.7'
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.7'
55
- description: ! 'Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]
56
-
54
+ version: '3.8'
55
+ description: |-
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
58
-
59
58
  libyaml, Psych also knows how to serialize and de-serialize most Ruby objects
60
-
61
- to and from the YAML format.'
59
+ to and from the YAML format.
62
60
  email:
63
61
  - aaron@tenderlovemaking.com
64
62
  executables: []
@@ -195,17 +193,17 @@ require_paths:
195
193
  - lib
196
194
  required_ruby_version: !ruby/object:Gem::Requirement
197
195
  requirements:
198
- - - ! '>='
196
+ - - '>='
199
197
  - !ruby/object:Gem::Version
200
198
  version: 1.9.2
201
199
  required_rubygems_version: !ruby/object:Gem::Requirement
202
200
  requirements:
203
- - - ! '>='
201
+ - - '>='
204
202
  - !ruby/object:Gem::Version
205
203
  version: '0'
206
204
  requirements: []
207
205
  rubyforge_project: psych-shopifork
208
- rubygems_version: 2.1.9
206
+ rubygems_version: 2.0.3
209
207
  signing_key:
210
208
  specification_version: 4
211
209
  summary: Psych is a YAML parser and emitter