Skip to content

Commit

Permalink
Merge pull request #12 from nfg/master
Browse files Browse the repository at this point in the history
Fixing RT #41141 -- handling carriage return after c-indicator.
  • Loading branch information
toddr committed Apr 17, 2017
2 parents b6a5215 + 191823b commit 89620ce
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion emitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ syck_scan_scalar( int req_width, char *cursor, long len )
}
if ( ( cursor[0] == '-' || cursor[0] == ':' ||
cursor[0] == '?' || cursor[0] == ',' ) &&
( cursor[1] == ' ' || cursor[1] == '\n' || len == 1 ) )
( cursor[1] == ' ' || cursor[1] == '\n' || cursor[1] == '\r' || len == 1 ) )
{
flags |= SCAN_INDIC_S;
}
Expand Down
31 changes: 31 additions & 0 deletions t/bug/rt-41141.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env perl

use strict;
use warnings;

use Test::More;
use YAML::Syck;
use Data::Dumper;

# Carrier returns after c-indicators aren't being handled properly.

my %tests = (
# From the original bug report. Seems to have been fixed already.
'42\\r' => "42\r",

# These all produced bad YAML.
'?\\r' => "?\r",
'-\\r\\r' => "-\r\r",
',\\r\\r\\r' => ",\r\r\r",
);

plan tests => scalar keys %tests;
while (my ($test, $value) = each (%tests))
{
my $yaml = YAML::Syck::Dump($value);
my $decoded = eval { YAML::Syck::Load($yaml); };
is($decoded, $value, "Produces valid YAML: $test");
}

note 'Done!';

0 comments on commit 89620ce

Please sign in to comment.