[otrs-cvs] otrs/Kernel/cpan-lib/YAML Loader.pm,1.3,1.4

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/otrs/Kernel/cpan-lib/YAML
In directory lancelot:/tmp/cvs-serv20963/Kernel/cpan-lib/YAML

Modified Files:
	Loader.pm 
Log Message:
 - 2013-01-15 Patched the module YAML::Loader to work around an open bug with parsing errors
    on large strings.

Author: mg

Index: Loader.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/cpan-lib/YAML/Loader.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -2 -u -d -r1.3 -r1.4
--- Loader.pm	16 Jul 2012 10:55:47 -0000	1.3
+++ Loader.pm	15 Jan 2013 11:41:59 -0000	1.4
@@ -17,6 +17,6 @@
 my $ESCAPE_CHAR = '[\\x00-\\x08\\x0b-\\x0d\\x0e-\\x1f]';
 my $FOLD_CHAR   = '>';
-my $LIT_CHAR    = '|';    
-my $LIT_CHAR_RX = "\\$LIT_CHAR";    
+my $LIT_CHAR    = '|';
+my $LIT_CHAR_RX = "\\$LIT_CHAR";
 
 sub load {
@@ -34,8 +34,8 @@
     $self->{stream} =~ s|\015|\012|g;
     $self->line(0);
-    $self->die('YAML_PARSE_ERR_BAD_CHARS') 
+    $self->die('YAML_PARSE_ERR_BAD_CHARS')
       if $self->stream =~ /$ESCAPE_CHAR/;
-    $self->die('YAML_PARSE_ERR_NO_FINAL_NEWLINE') 
-      if length($self->stream) and 
+    $self->die('YAML_PARSE_ERR_NO_FINAL_NEWLINE')
+      if length($self->stream) and
          $self->{stream} !~ s/(.)\n\Z/$1/s;
     $self->lines([split /\x0a/, $self->stream, -1]);
@@ -92,5 +92,5 @@
         $directives{YAML} ||= '1.0';
         $directives{TAB} ||= 'NONE';
-        ($self->{major_version}, $self->{minor_version}) = 
+        ($self->{major_version}, $self->{minor_version}) =
           split /\./, $directives{YAML}, 2;
         $self->die('YAML_PARSE_ERR_BAD_MAJOR_VERSION', $directives{YAML})
@@ -115,5 +115,5 @@
     my ($node, $type, $indicator, $escape, $chomp) = ('') x 5;
     my ($anchor, $alias, $explicit, $implicit, $class) = ('') x 5;
-    ($anchor, $alias, $explicit, $implicit, $preface) = 
+    ($anchor, $alias, $explicit, $implicit, $preface) =
       $self->_parse_qualifiers($preface);
     if ($anchor) {
@@ -123,5 +123,5 @@
     while (length $preface) {
         my $line = $self->line - 1;
-        if ($preface =~ s/^($FOLD_CHAR|$LIT_CHAR_RX)(-|\+)?\d*\s*//) { 
+        if ($preface =~ s/^($FOLD_CHAR|$LIT_CHAR_RX)(-|\+)?\d*\s*//) {
             $indicator = $1;
             $chomp = $2 if defined($2);
@@ -141,5 +141,5 @@
         else {
             $node = do {my $sv = "*$alias"};
-            push @{$self->anchor2node->{$alias}}, [\$node, $self->line]; 
+            push @{$self->anchor2node->{$alias}}, [\$node, $self->line];
         }
     }
@@ -147,5 +147,5 @@
         $node = $self->_parse_inline(1, $implicit, $explicit);
         if (length $self->inline) {
-            $self->die('YAML_PARSE_ERR_SINGLE_LINE'); 
+            $self->die('YAML_PARSE_ERR_SINGLE_LINE');
         }
     }
@@ -154,5 +154,5 @@
         $node = $self->_parse_block($chomp);
         $node = $self->_parse_implicit($node) if $implicit;
-        $self->{level}--; 
+        $self->{level}--;
     }
     elsif ($indicator eq $FOLD_CHAR) {
@@ -231,5 +231,5 @@
         elsif ($preface =~ s/^\&([^ ,:]+)\s*//) {
             $token = $1;
-            $self->die('YAML_PARSE_ERR_BAD_ANCHOR') 
+            $self->die('YAML_PARSE_ERR_BAD_ANCHOR')
               unless $token =~ /^[a-zA-Z0-9]+$/;
             $self->die('YAML_PARSE_ERR_MANY_ANCHOR') if $anchor;
@@ -246,8 +246,8 @@
         }
     }
-    return ($anchor, $alias, $explicit, $implicit, $preface); 
+    return ($anchor, $alias, $explicit, $implicit, $preface);
 }
 
-# Morph a node to it's explicit type  
+# Morph a node to it's explicit type
 sub _parse_explicit {
     my $self = shift;
@@ -266,5 +266,5 @@
             $node = \$value;
         }
-        
+
         if ( $type eq "scalar" and length($class) and !ref($node) ) {
             my $value = $node;
@@ -333,5 +333,5 @@
             $key = "$key";
         }
-        # If "default" key (equals sign) 
+        # If "default" key (equals sign)
         elsif ($self->{content} =~ s/^\=\s*//) {
             $key = VALUE;
@@ -349,5 +349,5 @@
             $self->inline('');
         }
-            
+
         unless ($self->{content} =~ s/^:\s*//) {
             $self->die('YAML_LOAD_ERR_BAD_MAP_ELEMENT');
@@ -405,5 +405,5 @@
     $self->{inline} =~ s/^\s*(.*)\s*$/$1/; # OUCH - mugwump
     my ($node, $anchor, $alias, $explicit, $implicit) = ('') x 5;
-    ($anchor, $alias, $explicit, $implicit, $self->{inline}) = 
+    ($anchor, $alias, $explicit, $implicit, $self->{inline}) =
       $self->_parse_qualifiers($self->inline);
     if ($anchor) {
@@ -421,5 +421,5 @@
         else {
             $node = do {my $sv = "*$alias"};
-            push @{$self->anchor2node->{$alias}}, [\$node, $self->line]; 
+            push @{$self->anchor2node->{$alias}}, [\$node, $self->line];
         }
     }
@@ -505,5 +505,5 @@
         push @$node, $value;
         next if $self->inline =~ /^\s*\]/;
-        $self->die('YAML_PARSE_ERR_INLINE_SEQUENCE') 
+        $self->die('YAML_PARSE_ERR_INLINE_SEQUENCE')
           unless $self->{inline} =~ s/^\,\s*//;
     }
@@ -515,5 +515,10 @@
     my $self = shift;
     my $node;
-    if ($self->inline =~ /^"((?:\\"|[^"])*)"\s*(.*)$/) {
+# --
+# OTRS PATCH
+# --
+#    if ($self->inline =~ /^"((?:\\"|[^"])*)"\s*(.*)$/) {
+    if ($self->inline =~ /^"((?:\\")*|[^"]*)"\s*(.*)$/) {
+# --
         $node = $1;
         $self->inline($2);
@@ -531,5 +536,10 @@
     my $self = shift;
     my $node;
-    if ($self->inline =~ /^'((?:''|[^'])*)'\s*(.*)$/) {
+# --
+# OTRS PATCH
+# --
+#    if ($self->inline =~ /^'((?:''|[^'])*)'\s*(.*)$/) {
+    if ($self->inline =~ /^'((?:'')*|[^']*)'\s*(.*)$/) {
+# --
         $node = $1;
         $self->inline($2);
@@ -622,5 +632,5 @@
 #   A) Skip over any throwaways (Comments/blanks)
 #   B) Set $self->indent, $self->content, $self->line
-# 4) Expand tabs appropriately  
+# 4) Expand tabs appropriately
 sub _parse_next_line {
     my $self = shift;
@@ -664,5 +674,5 @@
     }
     # Determine the offset for a new collection level
-    elsif ($type == COLLECTION and 
+    elsif ($type == COLLECTION and
            $self->preface =~ /^(\s*(\!\S*|\&\S+))*\s*$/) {
         $self->_parse_throwaway_comments();
@@ -682,5 +692,5 @@
         $offset = $self->offset->[++$level];
     }
-        
+
     if ($type == LEAF) {
         while (@{$self->lines} and
@@ -696,11 +706,11 @@
         $self->_parse_throwaway_comments();
     }
-    return if $self->eos; 
-    
+    return if $self->eos;
+
     if ($self->lines->[0] =~ /^---(\s|$)/) {
         $self->done(1);
         return;
     }
-    if ($type == LEAF and 
+    if ($type == LEAF and
         $self->lines->[0] =~ /^ {$offset}(.*)$/
        ) {
@@ -717,5 +727,5 @@
             $level--;
         }
-        $self->die('YAML_PARSE_ERR_INCONSISTENT_INDENTATION') 
+        $self->die('YAML_PARSE_ERR_INCONSISTENT_INDENTATION')
           if $self->offset->[$level] != length($1);
         $self->indent(length($1));
@@ -742,5 +752,5 @@
    '\\' => '\\',
   );
-   
+
 # Transform all the backslash style escape characters to their literal meaning
 sub _unescape {
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.