Blob Blame History Raw
--- lib/YAML/Loader.pm
+++ lib/YAML/Loader.pm
@@ -507,10 +507,27 @@ sub _parse_inline_seq {
     return $node;
 }
 
+# Work around /regexp/ bug in perl < 5.10
+sub _parse_inline_double_quoted_perl_bug_work_around {
+    my $self = shift;
+    my @list;
+    local $_ = $self->{inline};
+    s{^"}{} or croak YAML_PARSE_ERR_BAD_DOUBLE();
+    push @list, $1
+        while s{^((?:\\.|[^\"\\]+){1,1000})}{};
+    s/\\"/"/g for @list;
+    s{^"}{} or croak YAML_PARSE_ERR_BAD_DOUBLE();
+    $self->{inline} = $_;
+    return join("",@list);
+}
+
 # Parse the inline double quoted string.
 sub _parse_inline_double_quoted {
     my $self = shift;
     my $node;
+    # https://rt.cpan.org/Public/Bug/Display.html?id=18195
+    return $self->_parse_inline_double_quoted_perl_bug_work_around()
+        if length($self->{inline}) > 10_000;
     if ($self->inline =~ /^"((?:\\"|[^"])*)"\s*(.*)$/) {
         $node = $1;
         $self->inline($2);
--- t/rt-90593.t
+++ t/rt-90593.t
@@ -0,0 +1,14 @@
+# https://rt.cpan.org/Public/Bug/Display.html?id=90593
+use Test::More tests => 2;
+
+use YAML;
+use constant LENGTH => 1000000;
+
+$SIG{__WARN__} = sub { die @_ };
+
+my $yaml = 'x: "' . ('x' x LENGTH) . '"' . "\n";
+
+my $hash = Load $yaml;
+
+is ref($hash), 'HASH', 'Loaded a hash';
+is length($hash->{x}), LENGTH, 'Long scalar loaded';