Skip Menu |

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

Report information
The Basics
Id: 52432
Status: resolved
Priority: 0/
Queue: YAML-Syck

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

Bug Information
Severity: Important
Broken in: 1.07
Fixed in: (no value)



Subject: YAML::Syck does not quote keys that are 'dot-dot-dot-space-something', resulting in broken YAML
Howdy, I had a hash that had a key that happened to start w/ three dots for an ellipses and I kept getting corrupt YAML files. I narrowed it down this smallest case scenario: Compare: perl -MData::Dumper -MYAML::Syck -e 'my $y=YAML::Syck::Dump({ $ARGV[0] => ""});print $y;print Dumper(Load($y));' '... ' to perl -MData::Dumper -MYAML::Syck -e 'my $y=YAML::Syck::Dump({ $ARGV[0] => ""});print $y;print Dumper(Load($y));' '... X' If dot-dot-dot-space-something means something in YAML then it should be quoted if part of a data structure. I have verified that quoting it makes it valid again. --- ... X: '' to --- "... X": ''
(This is a form-reply that isn't specific to your particular report) YAML::Syck has just acquired one new maintainer (me), it still doesn't have anyone that *cares* about it. But I'm willing to help solve your report & release a new version with the fix if it's easy for me. It now has a Git repository at: http://github.com/avar/YAML-Syck If your report is a patch that fixes a problem, great. Please remake the patch against Git by forking that repo and sending me a pull request on GitHub (or an update to this bug if you prefer git-format-patch(1) or some other repo provider..). Make sure to include a test for what you fixed. If your report is some code that fails (and you have a testcase for it) a patch against the test suite to demonstrate that failure would be very useful. It's OK if the test crashes and burns, see Test::More's docs for how to make TODO tests that fail now, but shouldn't. Even if it segfaults perl C<system $^X => qw/ -Mblib -MYAML::Syck .../> or something like that and checking the return value will do.
I've added a TODO test for this in github. I don't know how to go about fixing it but it looks ugly.
Subject: patch.txt
commit 3d0cc99d6f946d38a05e0db401c2c2151a179465 Author: Todd Rinaldo <toddr@cpan.org> Date: Thu Jul 15 21:33:20 2010 -0500 Add tests for RT 52432 - '... X' breaks round trip diff --git a/t/2-scalars.t b/t/2-scalars.t index 69d797a..53eb89d 100644 --- a/t/2-scalars.t +++ b/t/2-scalars.t @@ -1,6 +1,4 @@ -use t::TestYAML tests => 88; - -local $SIG{__WARN__} = sub { 1 } if $Test::VERSION < 1.20; +use t::TestYAML tests => 89; ok(YAML::Syck->VERSION); @@ -153,7 +151,7 @@ is(Dump("\xff\xff"), "--- !binary //8=\n"); is(Load("--- !binary //8=\n"), "\xff\xff"); is(Dump("ascii"), "--- ascii\n"); -is(Dump("This is Perl 6 User's Golfing System\n", q[--- "This is Perl6 User's Golfing System\n"])); +is(Dump("This is Perl 6 User's Golfing System\n"), q[--- "This is Perl 6 User's Golfing System\n"] . "\n" ); $YAML::Syck::SingleQuote = $YAML::Syck::SingleQuote = 1; @@ -199,3 +197,11 @@ is(Dump('oN'), "--- oN\n"); # invalid case is(Dump('oFF'), "--- oFF\n"); # invalid case is(Dump('nULL'), "--- nULL\n"); # invalid case +# RT 52432 - '... X' +my $bad_hash = {'... X' => ''}; +my $bad_hash_should = "--- \n... X: ''\n"; +TODO: { + local $TODO; + $TODO = "roundtrip is breaking for this right now: '$bad_hash_should'"; + roundtrip($bad_hash); +} diff --git a/t/TestYAML.pm b/t/TestYAML.pm index dfa4d1a..3ed1dc9 100644 --- a/t/TestYAML.pm +++ b/t/TestYAML.pm @@ -3,7 +3,7 @@ package t::TestYAML; BEGIN { $ENV{PERL_DL_NONLAZY} = 0 } use strict; -use Test; +use Test::More; use YAML::Syck; sub import { @@ -12,7 +12,7 @@ sub import { plan @_; *::ok = *ok; - *::is = *ok; + *::is = *is; *::roundtrip = *roundtrip; *::Dump = *YAML::Syck::Dump; *::Load = *YAML::Syck::Load;
This looks like it could be fixed with something very similar to my ":foo" fix. I.e. just check if the string begins with ".", and if so always auto-escape it.
Ticket migrated to github as https://github.com/toddr/YAML-Syck/issues/31