The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
CONTRIBUTING 27
Changes 08
LibYAML/emitter.c 74
LibYAML/loader.c 012
LibYAML/parser.c 11
LibYAML/reader.c 37
LibYAML/scanner.c 1829
LibYAML/writer.c 11
LibYAML/yaml_private.h 524
META.json 11
META.yml 11
Makefile.PL 11
inc/Test/Base.pm 21
lib/YAML/LibYAML.pod 11
lib/YAML/XS.pm 11
lib/YAML/XS.pod 11
t/error.t 18
17 files changed (This is a version diff) 46108
@@ -9,7 +9,7 @@ help you be an effective contributor to the Project.
 GitHub
 ------
 
-The code for this Project is hosted at GitHub. The repository is:
+The code for this Project is hosted at GitHub. The URL is:
 
   https://github.com/ingydotnet/yaml-libyaml-pm
 
@@ -36,7 +36,7 @@ Zilla::Dist
 
 This Project uses Zilla::Dist to prepare it for publishing to CPAN. Read:
 
-  https://metacpan.org/pod/distribution/Zilla-Dist/lib/Zilla/Dist/Contributing.pod
+  https://metacpan.org/pod/Zilla::Dist::Contributing
 
 for up-to-date instructions on what contributors like yourself need to know to
 use it.
@@ -53,3 +53,8 @@ Join the channel. Join the team!
 
     Thanks in advance, Ingy döt Net
 
+
+
+
+
+# This file generated by Zilla-Dist-0.0.174
@@ -1,3 +1,11 @@
+0.54 Sat Nov 29 11:47:10 PST 2014
+ - Reverted an old patch with 0.53. Unreverted.
+
+0.53 Fri Nov 28 09:20:08 PST 2014
+ - Fix for
+   https://bitbucket.org/xi/libyaml/issue/10/wrapped-strings-cause-assert-f
+   ailure
+
 0.52 Fri Aug 22 21:03:19 PDT 2014
  - Fix e1 test failure on 5.21.4
 
@@ -517,7 +517,7 @@ yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
         if (emitter->best_width < 0) {
             emitter->best_width = INT_MAX;
         }
-
+        
         if (!emitter->line_break) {
             emitter->line_break = YAML_LN_BREAK;
         }
@@ -607,7 +607,7 @@ yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
             if (!yaml_emitter_write_indent(emitter))
                 return 0;
         }
-
+        
         if (event->data.document_start.tag_directives.start
                 != event->data.document_start.tag_directives.end) {
             implicit = 0;
@@ -721,7 +721,7 @@ yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
 }
 
 /*
- *
+ * 
  * Expect a flow item node.
  */
 
@@ -1402,7 +1402,7 @@ yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
 {
     size_t anchor_length;
     yaml_string_t string;
-
+    
     anchor_length = strlen((char *)anchor);
     STRING_ASSIGN(string, anchor, anchor_length);
 
@@ -1944,9 +1944,6 @@ yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
         }
     }
 
-    emitter->whitespace = 0;
-    emitter->indention = 0;
-
 /*
  * < rz> ingy: i'm not sure why i set open_ended in yaml_emitter_write_plain_scalar
  *
@@ -286,6 +286,8 @@ yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
     int index;
     yaml_char_t *tag = first_event->data.scalar.tag;
 
+    if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
+
     if (!tag || strcmp((char *)tag, "!") == 0) {
         yaml_free(tag);
         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)
     int index, item_index;
     yaml_char_t *tag = first_event->data.sequence_start.tag;
 
+    if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
+
     if (!tag || strcmp((char *)tag, "!") == 0) {
         yaml_free(tag);
         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)
     if (!yaml_parser_parse(parser, &event)) return 0;
 
     while (event.type != YAML_SEQUENCE_END_EVENT) {
+        if (!STACK_LIMIT(parser,
+                    parser->document->nodes.start[index-1].data.sequence.items,
+                    INT_MAX-1)) return 0;
         item_index = yaml_parser_load_node(parser, &event);
         if (!item_index) return 0;
         if (!PUSH(parser,
@@ -387,6 +394,8 @@ yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
     yaml_node_pair_t pair;
     yaml_char_t *tag = first_event->data.mapping_start.tag;
 
+    if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
+
     if (!tag || strcmp((char *)tag, "!") == 0) {
         yaml_free(tag);
         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)
     if (!yaml_parser_parse(parser, &event)) return 0;
 
     while (event.type != YAML_MAPPING_END_EVENT) {
+        if (!STACK_LIMIT(parser,
+                    parser->document->nodes.start[index-1].data.mapping.pairs,
+                    INT_MAX-1)) return 0;
         pair.key = yaml_parser_load_node(parser, &event);
         if (!pair.key) return 0;
         if (!yaml_parser_parse(parser, &event)) return 0;
@@ -1295,7 +1295,7 @@ yaml_parser_process_directives(yaml_parser_t *parser,
         token = PEEK_TOKEN(parser);
         if (!token) goto error;
     }
-
+    
     for (default_tag_directive = default_tag_directives;
             default_tag_directive->handle; default_tag_directive++) {
         if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
@@ -52,7 +52,7 @@ yaml_parser_determine_encoding(yaml_parser_t *parser)
 {
     /* Ensure that we had enough bytes in the raw buffer. */
 
-    while (!parser->eof
+    while (!parser->eof 
             && parser->raw_buffer.last - parser->raw_buffer.pointer < 3) {
         if (!yaml_parser_update_raw_buffer(parser)) {
             return 0;
@@ -295,7 +295,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
                                 parser->offset, value);
 
                     break;
-
+                
                 case YAML_UTF16LE_ENCODING:
                 case YAML_UTF16BE_ENCODING:
 
@@ -318,7 +318,7 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
                      *
                      * The following formulas are used for decoding
                      * and encoding characters using surrogate pairs:
-                     *
+                     * 
                      *  U  = U' + 0x10000   (0x01 00 00 <= U <= 0x10 FF FF)
                      *  U' = yyyyyyyyyyxxxxxxxxxx   (0 <= U' <= 0x0F FF FF)
                      *  W1 = 110110yyyyyyyyyy
@@ -460,6 +460,10 @@ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
 
     }
 
+    if (parser->offset >= PTRDIFF_MAX)
+        return yaml_parser_set_reader_error(parser, "input is too long",
+                PTRDIFF_MAX, -1);
+
     return 1;
 }
 
@@ -615,11 +615,11 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser);
  */
 
 static int
-yaml_parser_roll_indent(yaml_parser_t *parser, int column,
-        int number, yaml_token_type_t type, yaml_mark_t mark);
+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
+        ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark);
 
 static int
-yaml_parser_unroll_indent(yaml_parser_t *parser, int column);
+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column);
 
 /*
  * Token fetchers.
@@ -762,7 +762,7 @@ yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
     }
 
     /* Fetch the next token from the queue. */
-
+    
     *token = DEQUEUE(parser, parser->tokens);
     parser->token_available = 0;
     parser->tokens_parsed ++;
@@ -1103,14 +1103,16 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
      */
 
     int required = (!parser->flow_level
-            && parser->indent == (int)parser->mark.column);
+            && parser->indent == (ptrdiff_t)parser->mark.column);
 
     /*
      * A simple key is required only when it is the first token in the current
      * line.  Therefore it is always allowed.  But we add a check anyway.
      */
 
-    assert(parser->simple_key_allowed || !required);    /* Impossible. */
+    /* XXX This caused:
+     * https://bitbucket.org/xi/libyaml/issue/10/wrapped-strings-cause-assert-failure
+    assert(parser->simple_key_allowed || !required); */    /* Impossible. */
 
     /*
      * If the current position may start a simple key, save it.
@@ -1121,7 +1123,7 @@ yaml_parser_save_simple_key(yaml_parser_t *parser)
         yaml_simple_key_t simple_key;
         simple_key.possible = 1;
         simple_key.required = required;
-        simple_key.token_number =
+        simple_key.token_number = 
             parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
         simple_key.mark = parser->mark;
 
@@ -1176,6 +1178,11 @@ yaml_parser_increase_flow_level(yaml_parser_t *parser)
 
     /* Increase the flow level. */
 
+    if (parser->flow_level == INT_MAX) {
+        parser->error = YAML_MEMORY_ERROR;
+        return 0;
+    }
+
     parser->flow_level++;
 
     return 1;
@@ -1202,12 +1209,12 @@ yaml_parser_decrease_flow_level(yaml_parser_t *parser)
  * Push the current indentation level to the stack and set the new level
  * the current column is greater than the indentation level.  In this case,
  * append or insert the specified token into the token queue.
- *
+ * 
  */
 
 static int
-yaml_parser_roll_indent(yaml_parser_t *parser, int column,
-        int number, yaml_token_type_t type, yaml_mark_t mark)
+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
+        ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark)
 {
     yaml_token_t token;
 
@@ -1226,6 +1233,11 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column,
         if (!PUSH(parser, parser->indents, parser->indent))
             return 0;
 
+        if (column > INT_MAX) {
+            parser->error = YAML_MEMORY_ERROR;
+            return 0;
+        }
+
         parser->indent = column;
 
         /* Create a token and insert it into the queue. */
@@ -1254,7 +1266,7 @@ yaml_parser_roll_indent(yaml_parser_t *parser, int column,
 
 
 static int
-yaml_parser_unroll_indent(yaml_parser_t *parser, int column)
+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
 {
     yaml_token_t token;
 
@@ -1935,7 +1947,7 @@ yaml_parser_scan_to_next_token(yaml_parser_t *parser)
          *
          *  - in the flow context;
          *  - in the block context, but not at the beginning of the line or
-         *  after '-', '?', or ':' (complex value).
+         *  after '-', '?', or ':' (complex value).  
          */
 
         if (!CACHE(parser, 1)) return 0;
@@ -2574,7 +2586,7 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
 
     /* Resize the string to include the head. */
 
-    while (string.end - string.start <= (int)length) {
+    while ((size_t)(string.end - string.start) <= length) {
         if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
             parser->error = YAML_MEMORY_ERROR;
             goto error;
@@ -2619,6 +2631,9 @@ yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
         /* Check if it is a URI-escape sequence. */
 
         if (CHECK(parser->buffer, '%')) {
+            if (!STRING_EXTEND(parser, string))
+                goto error;
+
             if (!yaml_parser_scan_uri_escapes(parser,
                         directive, start_mark, &string)) goto error;
         }
@@ -3001,7 +3016,7 @@ yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
             *indent = 1;
     }
 
-   return 1;
+   return 1; 
 }
 
 /*
@@ -3156,10 +3171,6 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
                         *(string.pointer++) = '"';
                         break;
 
-                    case '/':
-                        *(string.pointer++) = '/';
-                        break;
-
                     case '\'':
                         *(string.pointer++) = '\'';
                         break;
@@ -74,7 +74,7 @@ yaml_emitter_flush(yaml_emitter_t *emitter)
         unsigned int value;
         size_t k;
 
-        /*
+        /* 
          * See the "reader.c" code for more details on UTF-8 encoding.  Note
          * that we assume that the buffer contains a valid UTF-8 sequence.
          */
@@ -1,13 +1,23 @@
 
 #if HAVE_CONFIG_H
 #include <config.h>
-#include "config.h"
 #endif
 
 #include <yaml.h>
 
 #include <assert.h>
 #include <limits.h>
+#include <stddef.h>
+
+#ifndef _MSC_VER
+#include <stdint.h>
+#else
+#ifdef _WIN64
+#define PTRDIFF_MAX _I64_MAX
+#else
+#define PTRDIFF_MAX INT_MAX
+#endif
+#endif
 
 /*
  * Memory management.
@@ -133,9 +143,12 @@ yaml_string_join(
      (string).start = (string).pointer = (string).end = 0)
 
 #define STRING_EXTEND(context,string)                                           \
-    (((string).pointer+5 < (string).end)                                        \
+    ((((string).pointer+5 < (string).end)                                       \
         || yaml_string_extend(&(string).start,                                  \
-            &(string).pointer, &(string).end))
+            &(string).pointer, &(string).end)) ?                                \
+         1 :                                                                    \
+        ((context)->error = YAML_MEMORY_ERROR,                                  \
+         0))
 
 #define CLEAR(context,string)                                                   \
     ((string).pointer = (string).start,                                         \
@@ -229,9 +242,9 @@ yaml_string_join(
         (string).pointer[offset] <= (yaml_char_t) 'f') ?                        \
        ((string).pointer[offset] - (yaml_char_t) 'a' + 10) :                    \
        ((string).pointer[offset] - (yaml_char_t) '0'))
-
+ 
 #define AS_HEX(string)  AS_HEX_AT((string),0)
-
+ 
 /*
  * Check if the character is ASCII.
  */
@@ -422,6 +435,12 @@ yaml_queue_extend(void **start, void **head, void **tail, void **end);
 #define STACK_EMPTY(context,stack)                                              \
     ((stack).start == (stack).top)
 
+#define STACK_LIMIT(context,stack,size)                                         \
+    ((stack).top - (stack).start < (size) ?                                     \
+        1 :                                                                     \
+        ((context)->error = YAML_MEMORY_ERROR,                                  \
+         0))
+
 #define PUSH(context,stack,value)                                               \
     (((stack).top != (stack).end                                                \
       || yaml_stack_extend((void **)&(stack).start,                             \
@@ -50,6 +50,6 @@
          "web" : "https://github.com/ingydotnet/yaml-libyaml-pm"
       }
    },
-   "version" : "0.52"
+   "version" : "0.54"
 }
 
@@ -24,4 +24,4 @@ resources:
   bugtracker: https://github.com/ingydotnet/yaml-libyaml-pm/issues
   homepage: https://github.com/ingydotnet/yaml-libyaml-pm
   repository: https://github.com/ingydotnet/yaml-libyaml-pm.git
-version: '0.52'
+version: '0.54'
@@ -20,7 +20,7 @@ my %WriteMakefileArgs = (
   "LICENSE" => "perl",
   "NAME" => "YAML::LibYAML",
   "PREREQ_PM" => {},
-  "VERSION" => "0.52",
+  "VERSION" => "0.54",
   "test" => {
     "TESTS" => "t/*.t"
   }
@@ -1,5 +1,5 @@
 package Test::Base;
-our $VERSION = '0.87';
+our $VERSION = '0.88';
 
 use Spiffy -Base;
 use Spiffy ':XXX';
@@ -508,7 +508,6 @@ sub _spec_init {
     local $/;
     my $spec;
     if (my $spec_file = $self->_spec_file) {
-        warn "$spec_file";
         open FILE, $spec_file or die $!;
         $spec = <FILE>;
         close FILE;
@@ -1,7 +1,7 @@
 =pod
 
 =for comment
-DO NOT EDIT. This Pod was generated by Swim.
+DO NOT EDIT. This Pod was generated by Swim v0.1.31.
 See http://github.com/ingydotnet/swim-pm#readme
 
 =encoding utf8
@@ -1,7 +1,7 @@
 use strict; use warnings;
 
 package YAML::XS;
-our $VERSION = '0.52';
+our $VERSION = '0.54';
 
 use base 'Exporter';
 
@@ -1,7 +1,7 @@
 =pod
 
 =for comment
-DO NOT EDIT. This Pod was generated by Swim.
+DO NOT EDIT. This Pod was generated by Swim v0.1.31.
 See http://github.com/ingydotnet/swim-pm#readme
 
 =encoding utf8
@@ -1,4 +1,4 @@
-use t::TestYAMLTests tests => 24;
+use t::TestYAMLTests tests => 25;
 
 filters {
     error => ['lines', 'chomp'],
@@ -78,3 +78,10 @@ bad tag found for hash: 'tag:yaml.org,2002:!foo'
 document: 1
 !line:
 !column:
+
+=== https://bitbucket.org/xi/libyaml/issue/10/wrapped-strings-cause-assert-failure
++++ yaml
+  x: "
+" y: z
++++ error
+did not find expected key