Skip Menu |

This queue is for tickets about the YAML-Tiny CPAN distribution.

Report information
The Basics
Id: 52320
Status: resolved
Priority: 0/
Queue: YAML-Tiny

People
Owner: Nobody in particular
Requestors: jloverso [...] mathworks.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in:
  • 1.32
  • 1.34_01
  • 1.35
  • 1.36
  • 1.37
  • 1.38
  • 1.39
  • 1.40
Fixed in: 1.57



Subject: [PATCH] Writes YAML with empty keys it cannot read back
When I upgraded from 1.28 to 1.32 (and then 1.40), existing logic broke. My logic was saving YAML for a hash that happened to have a key that is an empty string. All versions of YAML::Tiny will generate identical output, but as of 1.32 (at least), it will croak while trying to parse the YAML it wrote. With 1.32, the error is (see attachments for 'yt2'): $ /usr/bin/perl yt2 $VAR1 = '--- data: allocating: attribute: cfg200801;pref=siteBLR cwaiting: SINGLEUSE&cfg200801;pref=siteBLR: 9 cfg200801;pref=siteBLR: 831 waiting: : 831 SINGLEUSE: 9 '; Bad or unsupported hash line at /Library/Perl/Updates/5.8.8/YAML/Tiny.pm line 268. With 1.40, it changes to: YAML::Tiny failed to classify line ' : 831' at yt2 line 30 The patch is very simple: move the error check for [?'"] outside of the pattern for matching the key. See attached Tiny.pm.patch --- Tiny.pm 2009-07-31 09:35:23.000000000 -0400 +++ Tiny.fixed.pm 2009-12-01 08:42:33.000000000 -0500 @@ -326,10 +326,10 @@ } # Get the key - unless ( $lines->[0] =~ s/^\s*([^\'\" ][^\n]*?)\s*:(\s+|$)// ) { - if ( $lines->[0] =~ /^\s*[?\'\"]/ ) { - croak("YAML::Tiny does not support a feature in line '$lines->[0]'"); - } + if ( $lines->[0] =~ /^\s*[?\'\"]/ ) { + croak("YAML::Tiny does not support a feature in line '$ lines->[0]'"); + } + unless ( $lines->[0] =~ s/^\s*([^\n]*?)\s*:(\s+|$)// ) { croak("YAML::Tiny failed to classify line '$lines->[0]'" ); } my $key = $1;
Subject: yt2
Download yt2
application/octet-stream 583b

Message body not shown because it is not plain text.

Subject: Tiny.pm.patch
--- Tiny.pm 2009-07-31 09:35:23.000000000 -0400 +++ Tiny.fixed.pm 2009-12-01 08:42:33.000000000 -0500 @@ -326,10 +326,10 @@ } # Get the key - unless ( $lines->[0] =~ s/^\s*([^\'\" ][^\n]*?)\s*:(\s+|$)// ) { - if ( $lines->[0] =~ /^\s*[?\'\"]/ ) { - croak("YAML::Tiny does not support a feature in line '$lines->[0]'"); - } + if ( $lines->[0] =~ /^\s*[?\'\"]/ ) { + croak("YAML::Tiny does not support a feature in line '$lines->[0]'"); + } + unless ( $lines->[0] =~ s/^\s*([^\n]*?)\s*:(\s+|$)// ) { croak("YAML::Tiny failed to classify line '$lines->[0]'"); } my $key = $1;
This has been fixed -- sort of -- in the repository. Quoted keys are now supported, so you can write YAML with a quoted empty string key and it will round-trip correctly. Marking this 'patched' until released.
released in 1.57