Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: ADIE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.03
Fixed in: (no value)



Subject: Dies on read for hash keys containing spaces
Doesn't handle hash keys with spaces in on read. See failing test attached. Not sure if fixing this fits within the remit of the "tiny" philosophy. If not maybe an error on write would be nice so at least the read/write is symmetric.
Subject: yaml.pl
#! /usr/bin/perl use strict; use warnings; use YAML::Tiny; use YAML; use Test::More tests => 1; my $test_description = 'got correct from key with space'; my ( $key, $value ) = ( "the key", "the value" ); my $writer = YAML::Tiny->new; $writer->[0]->{ $key } = $value; eval { my $reader = YAML::Tiny->read_string( $writer->write_string ); is $reader->[0]->{ $key }, $value, $test_description; }; if (my $e = $@) { fail $test_description; diag $e }
From: john [...] nixnuts.net
The fix for this is a minor change to line 246. Patch attached.
--- Tiny.pm.orig 2007-04-23 10:42:15.000000000 -0500 +++ Tiny.pm 2007-04-23 10:46:39.000000000 -0500 @@ -243,7 +243,7 @@ } # Get the key - unless ( $lines->[0] =~ s/^\s*(\S+)\s*:(\s+|$)// ) { + unless ( $lines->[0] =~ s/^\s*(\S[^:]*?)\s*:(\s+|$)// ) { die "Bad hash line"; } my $key = $1;
From: john [...] nixnuts.net
On Mon Apr 23 12:01:58 2007, lightsey wrote: Show quoted text
> The fix for this is a minor change to line 246. Patch attached.
Sorry, the patch I sent earlier causes a regression (hash keys with colons aren't parsed correctly.) A better fix is attached.
--- Tiny.pm.orig 2007-04-23 10:42:15.000000000 -0500 +++ Tiny.pm 2007-04-23 15:19:05.000000000 -0500 @@ -243,7 +243,7 @@ } # Get the key - unless ( $lines->[0] =~ s/^\s*(\S+)\s*:(\s+|$)// ) { + unless ( $lines->[0] =~ s/^\s*(\S.*?)\s*:(\s+|$)// ) { die "Bad hash line"; } my $key = $1;
Added a test to confirm this was fixed a few versions ago