Hello community, here is the log from the commit of package perl-YAML-PP for openSUSE:Factory checked in at 2020-07-15 15:04:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-YAML-PP (Old) and /work/SRC/openSUSE:Factory/.perl-YAML-PP.new.3060 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-YAML-PP" Wed Jul 15 15:04:58 2020 rev:6 rq:820833 version:0.023 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-YAML-PP/perl-YAML-PP.changes 2020-05-07 14:54:00.534245002 +0200 +++ /work/SRC/openSUSE:Factory/.perl-YAML-PP.new.3060/perl-YAML-PP.changes 2020-07-15 15:05:17.787426212 +0200 @@ -1,0 +2,15 @@ +Fri Jul 10 09:45:38 UTC 2020 - Tina Müller <[email protected]> + +- updated to 0.023 + see /usr/share/doc/packages/perl-YAML-PP/Changes + + 0.023 2020-07-09 22:09:50+02:00 + + - Support loading and dumping typeglobs. Issue #15 + - Dumper: Don't use aliases for JSON::PP/boolean.pm booleans, because they + alwas use the same reference. Issue #32 + - Fix float comparison in test. Issue #33 + - Make aliases in custom tags work + - YAML::PP::Highlight: colorize mapping keys + +------------------------------------------------------------------- Old: ---- YAML-PP-0.022.tar.gz New: ---- YAML-PP-0.023.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-YAML-PP.spec ++++++ --- /var/tmp/diff_new_pack.Aa3rMr/_old 2020-07-15 15:05:18.923427320 +0200 +++ /var/tmp/diff_new_pack.Aa3rMr/_new 2020-07-15 15:05:18.931427328 +0200 @@ -17,7 +17,7 @@ Name: perl-YAML-PP -Version: 0.022 +Version: 0.023 Release: 0 %define cpan_name YAML-PP Summary: YAML 1.2 processor ++++++ YAML-PP-0.022.tar.gz -> YAML-PP-0.023.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/Changes new/YAML-PP-0.023/Changes --- old/YAML-PP-0.022/Changes 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/Changes 2020-07-09 22:13:35.000000000 +0200 @@ -1,5 +1,14 @@ Revision history for Perl module YAML::PP +0.023 2020-07-09 22:09:50+02:00 + + - Support loading and dumping typeglobs. Issue #15 + - Dumper: Don't use aliases for JSON::PP/boolean.pm booleans, because they + alwas use the same reference. Issue #32 + - Fix float comparison in test. Issue #33 + - Make aliases in custom tags work + - YAML::PP::Highlight: colorize mapping keys + 0.022 2020-05-04 17:40:36+02:00 - Emitter: Also quote if string starts with '...' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/MANIFEST new/YAML-PP-0.023/MANIFEST --- old/YAML-PP-0.022/MANIFEST 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/MANIFEST 2020-07-09 22:13:35.000000000 +0200 @@ -105,6 +105,8 @@ t/50.clone.t t/51.directives.t t/52.preserve.t +t/53.customtag-alias.t +t/54.glob.t t/data/include/circular1.yaml t/data/include/circular2.yaml t/data/include/include.yaml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/META.json new/YAML-PP-0.023/META.json --- old/YAML-PP-0.022/META.json 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/META.json 2020-07-09 22:13:35.000000000 +0200 @@ -50,6 +50,7 @@ "requires" : { "File::Spec" : "0", "FindBin" : "0", + "IO::File" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::Deep" : "0", @@ -64,127 +65,127 @@ "provides" : { "YAML::PP" : { "file" : "lib/YAML/PP.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Common" : { "file" : "lib/YAML/PP/Common.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Constructor" : { "file" : "lib/YAML/PP/Constructor.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Dumper" : { "file" : "lib/YAML/PP/Dumper.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Emitter" : { "file" : "lib/YAML/PP/Emitter.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Exception" : { "file" : "lib/YAML/PP/Exception.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Grammar" : { "file" : "lib/YAML/PP/Grammar.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Highlight" : { "file" : "lib/YAML/PP/Highlight.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Lexer" : { "file" : "lib/YAML/PP/Lexer.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Loader" : { "file" : "lib/YAML/PP/Loader.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Parser" : { "file" : "lib/YAML/PP/Parser.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Perl" : { "file" : "lib/YAML/PP/Perl.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Preserve::Hash" : { "file" : "lib/YAML/PP.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Preserve::Scalar" : { "file" : "lib/YAML/PP.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Reader" : { "file" : "lib/YAML/PP/Reader.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Reader::File" : { "file" : "lib/YAML/PP/Reader.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Render" : { "file" : "lib/YAML/PP/Render.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Representer" : { "file" : "lib/YAML/PP/Representer.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema" : { "file" : "lib/YAML/PP/Schema.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::Binary" : { "file" : "lib/YAML/PP/Schema/Binary.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::Core" : { "file" : "lib/YAML/PP/Schema/Core.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::Failsafe" : { "file" : "lib/YAML/PP/Schema/Failsafe.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::Include" : { "file" : "lib/YAML/PP/Schema/Include.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::JSON" : { "file" : "lib/YAML/PP/Schema/JSON.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::Merge" : { "file" : "lib/YAML/PP/Schema/Merge.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::Perl" : { "file" : "lib/YAML/PP/Schema/Perl.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::Tie::IxHash" : { "file" : "lib/YAML/PP/Schema/Tie/IxHash.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Schema::YAML1_1" : { "file" : "lib/YAML/PP/Schema/YAML1_1.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Type::MergeKey" : { "file" : "lib/YAML/PP/Type/MergeKey.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Writer" : { "file" : "lib/YAML/PP/Writer.pm", - "version" : "0.022" + "version" : "0.023" }, "YAML::PP::Writer::File" : { "file" : "lib/YAML/PP/Writer/File.pm", - "version" : "0.022" + "version" : "0.023" } }, "release_status" : "stable", @@ -198,7 +199,7 @@ "web" : "https://github.com/perlpunk/YAML-PP-p5" } }, - "version" : "0.022", + "version" : "0.023", "x_generated_by_perl" : "v5.24.1", "x_serialization_backend" : "Cpanel::JSON::XS version 4.19" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/META.yml new/YAML-PP-0.023/META.yml --- old/YAML-PP-0.022/META.yml 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/META.yml 2020-07-09 22:13:35.000000000 +0200 @@ -5,6 +5,7 @@ build_requires: File::Spec: '0' FindBin: '0' + IO::File: '0' IO::Handle: '0' IPC::Open3: '0' Test::Deep: '0' @@ -25,97 +26,97 @@ provides: YAML::PP: file: lib/YAML/PP.pm - version: '0.022' + version: '0.023' YAML::PP::Common: file: lib/YAML/PP/Common.pm - version: '0.022' + version: '0.023' YAML::PP::Constructor: file: lib/YAML/PP/Constructor.pm - version: '0.022' + version: '0.023' YAML::PP::Dumper: file: lib/YAML/PP/Dumper.pm - version: '0.022' + version: '0.023' YAML::PP::Emitter: file: lib/YAML/PP/Emitter.pm - version: '0.022' + version: '0.023' YAML::PP::Exception: file: lib/YAML/PP/Exception.pm - version: '0.022' + version: '0.023' YAML::PP::Grammar: file: lib/YAML/PP/Grammar.pm - version: '0.022' + version: '0.023' YAML::PP::Highlight: file: lib/YAML/PP/Highlight.pm - version: '0.022' + version: '0.023' YAML::PP::Lexer: file: lib/YAML/PP/Lexer.pm - version: '0.022' + version: '0.023' YAML::PP::Loader: file: lib/YAML/PP/Loader.pm - version: '0.022' + version: '0.023' YAML::PP::Parser: file: lib/YAML/PP/Parser.pm - version: '0.022' + version: '0.023' YAML::PP::Perl: file: lib/YAML/PP/Perl.pm - version: '0.022' + version: '0.023' YAML::PP::Preserve::Hash: file: lib/YAML/PP.pm - version: '0.022' + version: '0.023' YAML::PP::Preserve::Scalar: file: lib/YAML/PP.pm - version: '0.022' + version: '0.023' YAML::PP::Reader: file: lib/YAML/PP/Reader.pm - version: '0.022' + version: '0.023' YAML::PP::Reader::File: file: lib/YAML/PP/Reader.pm - version: '0.022' + version: '0.023' YAML::PP::Render: file: lib/YAML/PP/Render.pm - version: '0.022' + version: '0.023' YAML::PP::Representer: file: lib/YAML/PP/Representer.pm - version: '0.022' + version: '0.023' YAML::PP::Schema: file: lib/YAML/PP/Schema.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::Binary: file: lib/YAML/PP/Schema/Binary.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::Core: file: lib/YAML/PP/Schema/Core.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::Failsafe: file: lib/YAML/PP/Schema/Failsafe.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::Include: file: lib/YAML/PP/Schema/Include.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::JSON: file: lib/YAML/PP/Schema/JSON.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::Merge: file: lib/YAML/PP/Schema/Merge.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::Perl: file: lib/YAML/PP/Schema/Perl.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::Tie::IxHash: file: lib/YAML/PP/Schema/Tie/IxHash.pm - version: '0.022' + version: '0.023' YAML::PP::Schema::YAML1_1: file: lib/YAML/PP/Schema/YAML1_1.pm - version: '0.022' + version: '0.023' YAML::PP::Type::MergeKey: file: lib/YAML/PP/Type/MergeKey.pm - version: '0.022' + version: '0.023' YAML::PP::Writer: file: lib/YAML/PP/Writer.pm - version: '0.022' + version: '0.023' YAML::PP::Writer::File: file: lib/YAML/PP/Writer/File.pm - version: '0.022' + version: '0.023' requires: B: '0' B::Deparse: '0' @@ -138,6 +139,6 @@ resources: bugtracker: https://github.com/perlpunk/YAML-PP-p5/issues repository: https://github.com/perlpunk/YAML-PP-p5 -version: '0.022' +version: '0.023' x_generated_by_perl: v5.24.1 x_serialization_backend: 'YAML::Tiny version 1.73' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/Makefile.PL new/YAML-PP-0.023/Makefile.PL --- old/YAML-PP-0.022/Makefile.PL 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/Makefile.PL 2020-07-09 22:13:35.000000000 +0200 @@ -50,6 +50,7 @@ "TEST_REQUIRES" => { "File::Spec" => 0, "FindBin" => 0, + "IO::File" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::Deep" => 0, @@ -58,7 +59,7 @@ "blib" => "1.01", "lib" => 0 }, - "VERSION" => "0.022", + "VERSION" => "0.023", "test" => { "TESTS" => "t/*.t" } @@ -76,6 +77,7 @@ "File::Spec" => 0, "FindBin" => 0, "Getopt::Long" => 0, + "IO::File" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "MIME::Base64" => 0, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/README new/YAML-PP-0.023/README --- old/YAML-PP-0.022/README 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/README 2020-07-09 22:13:35.000000000 +0200 @@ -1,5 +1,5 @@ This archive contains the distribution YAML-PP, -version 0.022: +version 0.023: YAML 1.2 Processor diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/bin/yamlpp-parse-emit new/YAML-PP-0.023/bin/yamlpp-parse-emit --- old/YAML-PP-0.022/bin/yamlpp-parse-emit 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/bin/yamlpp-parse-emit 2020-07-09 22:13:35.000000000 +0200 @@ -38,6 +38,9 @@ $parser->parse_string($yaml); }; if ($@) { + for (@events) { + print YAML::PP::Common::event_to_test_suite($_) ."\n"; + } warn "Error parsing: $@"; exit 1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/bin/yamlpp5-parse-emit new/YAML-PP-0.023/bin/yamlpp5-parse-emit --- old/YAML-PP-0.022/bin/yamlpp5-parse-emit 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/bin/yamlpp5-parse-emit 2020-07-09 22:13:35.000000000 +0200 @@ -38,6 +38,9 @@ $parser->parse_string($yaml); }; if ($@) { + for (@events) { + print YAML::PP::Common::event_to_test_suite($_) ."\n"; + } warn "Error parsing: $@"; exit 1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/dist.ini new/YAML-PP-0.023/dist.ini --- old/YAML-PP-0.022/dist.ini 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/dist.ini 2020-07-09 22:13:35.000000000 +0200 @@ -4,7 +4,7 @@ copyright_holder = Tina Müller copyright_year = 2020 -version = 0.022 +version = 0.023 [@Filter] -bundle = @Basic diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Common.pm new/YAML-PP-0.023/lib/YAML/PP/Common.pm --- old/YAML-PP-0.022/lib/YAML/PP/Common.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Common.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Common; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use base 'Exporter'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Constructor.pm new/YAML-PP-0.023/lib/YAML/PP/Constructor.pm --- old/YAML-PP-0.022/lib/YAML/PP/Constructor.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Constructor.pm 2020-07-09 22:13:35.000000000 +0200 @@ -3,7 +3,7 @@ use warnings; package YAML::PP::Constructor; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use YAML::PP; use YAML::PP::Common qw/ PRESERVE_ALL PRESERVE_ORDER PRESERVE_SCALAR_STYLE /; @@ -118,7 +118,7 @@ my $ref = { type => 'mapping', ref => [], - data => $data, + data => \$data, event => $event, on_data => $on_data, }; @@ -171,8 +171,8 @@ } for my $merge (@merge_keys) { for my $key (keys %$merge) { - unless (exists $data->{ $key }) { - $data->{ $key } = $merge->{ $key }; + unless (exists $$data->{ $key }) { + $$data->{ $key } = $merge->{ $key }; } } } @@ -187,8 +187,8 @@ $$hash->{ $key } = $value; } }; - $on_data->($self, \$data, \@ref); - push @{ $stack->[-1]->{ref} }, $data; + $on_data->($self, $data, \@ref); + push @{ $stack->[-1]->{ref} }, $$data; if (defined(my $anchor = $last->{event}->{anchor})) { $self->anchors->{ $anchor }->{finished} = 1; } @@ -201,7 +201,7 @@ my $ref = { type => 'sequence', ref => [], - data => $data, + data => \$data, event => $event, on_data => $on_data, }; @@ -224,9 +224,10 @@ my ($self, $array, $items) = @_; push @$$array, @$items; }; - $on_data->($self, \$data, $ref); - push @{ $stack->[-1]->{ref} }, $data; + $on_data->($self, $data, $ref); + push @{ $stack->[-1]->{ref} }, $$data; if (defined(my $anchor = $last->{event}->{anchor})) { + my $test = $self->anchors->{ $anchor }; $self->anchors->{ $anchor }->{finished} = 1; } return; @@ -241,7 +242,7 @@ DEBUG and warn "CONTENT $event->{value} ($event->{style})\n"; my $value = $self->schema->load_scalar($self, $event); if (defined (my $name = $event->{anchor})) { - $self->anchors->{ $name } = { data => $value, finished => 1 }; + $self->anchors->{ $name } = { data => \$value, finished => 1 }; } my $last = $self->stack->[-1]; if ($self->preserve_scalar_style and not ref $value) { @@ -268,18 +269,18 @@ die "Found cyclic ref"; } if ($cyclic_refs eq 'warn') { - $anchor = { data => undef }; + $anchor = { data => \undef }; warn "Found cyclic ref"; } elsif ($cyclic_refs eq 'ignore') { - $anchor = { data => undef }; + $anchor = { data => \undef }; } } } $value = $anchor->{data}; } my $last = $self->stack->[-1]; - push @{ $last->{ref} }, $value; + push @{ $last->{ref} }, $$value; } sub stringify_complex { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Dumper.pm new/YAML-PP-0.023/lib/YAML/PP/Dumper.pm --- old/YAML-PP-0.022/lib/YAML/PP/Dumper.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Dumper.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Dumper; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use Scalar::Util qw/ blessed refaddr reftype /; use YAML::PP; @@ -219,6 +219,7 @@ CODE => 1, SCALAR => 1, REF => 1, + GLOB => 1, ); sub check_references { @@ -226,6 +227,13 @@ my $reftype = reftype $doc or return; my $seen = $self->{seen}; # check which references are used more than once + if ($reftype eq 'SCALAR' and ref $doc eq $self->representer->schema->bool_class) { + # JSON::PP and boolean.pm always return the same reference for booleans + # Avoid printing *aliases in those case + if (ref $doc eq 'boolean' or ref $doc eq 'JSON::PP::Boolean') { + return; + } + } if (++$seen->{ refaddr $doc } > 1) { # seen already return; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Emitter.pm new/YAML-PP-0.023/lib/YAML/PP/Emitter.pm --- old/YAML-PP-0.022/lib/YAML/PP/Emitter.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Emitter.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Emitter; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use Data::Dumper; use YAML::PP::Common qw/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Exception.pm new/YAML-PP-0.023/lib/YAML/PP/Exception.pm --- old/YAML-PP-0.022/lib/YAML/PP/Exception.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Exception.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Exception; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use overload '""' => \&to_string; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Grammar.pm new/YAML-PP-0.023/lib/YAML/PP/Grammar.pm --- old/YAML-PP-0.022/lib/YAML/PP/Grammar.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Grammar.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Grammar; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use base 'Exporter'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Highlight.pm new/YAML-PP-0.023/lib/YAML/PP/Highlight.pm --- old/YAML-PP-0.022/lib/YAML/PP/Highlight.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Highlight.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Highlight; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION our @EXPORT_OK = qw/ Dump /; @@ -55,6 +55,7 @@ FLOWMAP_START => [qw/ bold magenta /], FLOWMAP_END => [qw/ bold magenta /], FLOW_COMMA => [qw/ bold magenta /], + PLAINKEY => [qw/ bright_blue /], ); sub ansicolored { @@ -79,7 +80,7 @@ $highlighted .= $str; } - $ansi .= "$highlighted\n"; + $ansi .= $highlighted; return $ansi; } @@ -114,6 +115,7 @@ FLOWMAP_START => 'flowmap_start', FLOWMAP_END => 'flowmap_end', FLOW_COMMA => 'flow_comma', + PLAINKEY => 'plainkey', ); sub htmlcolored { require HTML::Entities; @@ -163,6 +165,16 @@ } } elsif ($i < $#list) { + if ($name eq 'PLAIN') { + for my $n ($i+1 .. $#list) { + my $next = $list[ $n ]; + last if $next->{name} eq 'EOL'; + next if $next->{name} =~ m/^(WS|SPACE)$/; + if ($next->{name} eq 'COLON') { + $token->{name} = 'PLAINKEY'; + } + } + } my $next = $list[ $i + 1]; if ($next->{name} eq 'EOL') { if ($str =~ m/ \z/ and $name =~ m/^(BLOCK_SCALAR_CONTENT|WS)$/) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Lexer.pm new/YAML-PP-0.023/lib/YAML/PP/Lexer.pm --- old/YAML-PP-0.022/lib/YAML/PP/Lexer.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Lexer.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Lexer; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use constant TRACE => $ENV{YAML_PP_TRACE} ? 1 : 0; use constant DEBUG => ($ENV{YAML_PP_DEBUG} || $ENV{YAML_PP_TRACE}) ? 1 : 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Loader.pm new/YAML-PP-0.023/lib/YAML/PP/Loader.pm --- old/YAML-PP-0.022/lib/YAML/PP/Loader.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Loader.pm 2020-07-09 22:13:35.000000000 +0200 @@ -3,7 +3,7 @@ use warnings; package YAML::PP::Loader; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use YAML::PP::Parser; use YAML::PP::Constructor; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Parser.pm new/YAML-PP-0.023/lib/YAML/PP/Parser.pm --- old/YAML-PP-0.022/lib/YAML/PP/Parser.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Parser.pm 2020-07-09 22:13:35.000000000 +0200 @@ -3,7 +3,7 @@ use warnings; package YAML::PP::Parser; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use constant TRACE => $ENV{YAML_PP_TRACE} ? 1 : 0; use constant DEBUG => ($ENV{YAML_PP_DEBUG} || $ENV{YAML_PP_TRACE}) ? 1 : 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Perl.pm new/YAML-PP-0.023/lib/YAML/PP/Perl.pm --- old/YAML-PP-0.022/lib/YAML/PP/Perl.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Perl.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Perl; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use base 'Exporter'; use base 'YAML::PP'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Reader.pm new/YAML-PP-0.023/lib/YAML/PP/Reader.pm --- old/YAML-PP-0.022/lib/YAML/PP/Reader.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Reader.pm 2020-07-09 22:13:35.000000000 +0200 @@ -3,7 +3,7 @@ use warnings; package YAML::PP::Reader; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION sub input { return $_[0]->{input} } sub set_input { $_[0]->{input} = $_[1] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Render.pm new/YAML-PP-0.023/lib/YAML/PP/Render.pm --- old/YAML-PP-0.022/lib/YAML/PP/Render.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Render.pm 2020-07-09 22:13:35.000000000 +0200 @@ -3,7 +3,7 @@ use warnings; package YAML::PP::Render; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use constant TRACE => $ENV{YAML_PP_TRACE} ? 1 : 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Representer.pm new/YAML-PP-0.023/lib/YAML/PP/Representer.pm --- old/YAML-PP-0.022/lib/YAML/PP/Representer.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Representer.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Representer; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use Scalar::Util qw/ reftype blessed refaddr /; @@ -60,8 +60,11 @@ } } $node->{reftype} = reftype($node->{value}); + if (not $node->{reftype} and reftype(\$node->{value}) eq 'GLOB') { + $node->{reftype} = 'GLOB'; + } - if (ref $node->{value}) { + if ($node->{reftype}) { $self->represent_noderef($node); } else { @@ -185,6 +188,10 @@ my $code = $coderef->{code}; return 1 if $code->($self, $node); } + if ($node->{reftype} eq 'GLOB' and my $glob = $representers->{glob}) { + my $code = $glob->{code}; + return 1 if $code->($self, $node); + } $node->{data} = $node->{value}; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/Binary.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/Binary.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/Binary.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/Binary.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::Binary; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use MIME::Base64 qw/ decode_base64 encode_base64 /; use YAML::PP::Common qw/ YAML_ANY_SCALAR_STYLE /; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/Core.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/Core.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/Core.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/Core.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::Core; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use YAML::PP::Schema::JSON qw/ represent_int represent_float represent_literal represent_bool diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/Failsafe.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/Failsafe.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/Failsafe.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/Failsafe.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::Failsafe; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION sub register { my ($self, %args) = @_; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/Include.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/Include.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/Include.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/Include.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::Include; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use Carp qw/ croak /; use Scalar::Util qw/ weaken /; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/JSON.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/JSON.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/JSON.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/JSON.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::JSON; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use base 'Exporter'; our @EXPORT_OK = qw/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/Merge.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/Merge.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/Merge.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/Merge.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::Merge; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use YAML::PP::Type::MergeKey; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/Perl.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/Perl.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/Perl.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/Perl.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::Perl; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use Scalar::Util qw/ blessed reftype /; @@ -98,6 +98,7 @@ } } + # Code if ($loadcode) { my $load_code = sub { my ($constructor, $event) = @_; @@ -151,6 +152,45 @@ ) if $no_objects; } + # Glob + my $load_glob = sub { + my $value = undef; + return \$value; + }; + my $load_glob_blessed = sub { + my ($constructor, $event) = @_; + my $class = $event->{tag}; + $class =~ s{^$perl_regex/glob:}{}; + my $value = undef; + return $self->object(\$value, $class); + }; + + $schema->add_mapping_resolver( + tag => "$_/glob", + on_create => $load_glob, + on_data => sub { + my ($constructor, $ref, $list) = @_; + $$ref = $self->construct_glob($list); + }, + ) for @perl_tags; + $schema->add_mapping_resolver( + tag => qr{^$perl_regex/glob:$class_regex$}, + on_create => $load_glob_blessed, + on_data => sub { + my ($constructor, $ref, $list) = @_; + $$$ref = $self->construct_glob($list); + }, + ); + $schema->add_mapping_resolver( + tag => qr{^$perl_regex/glob:.+$}, + on_create => $load_glob, + on_data => sub { + my ($constructor, $ref, $list) = @_; + $$ref = $self->construct_glob($list); + }, + ) if $no_objects; + + # Regex my $load_regex = sub { my ($constructor, $event) = @_; return $self->construct_regex($event->{value}); @@ -218,6 +258,7 @@ on_create => $load_mapping, ) if $no_objects; + # Ref my $load_ref = sub { my $value = undef; return \$value; @@ -254,6 +295,7 @@ }, ) if $no_objects; + # Scalar ref my $load_scalar_ref = sub { my $value = undef; return \$value; @@ -314,6 +356,14 @@ $node->{data} = $self->represent_code($node->{value}); }, ); + $schema->add_representer( + glob => 1, + code => sub { + my ($rep, $node) = @_; + $node->{tag} = $perl_tag . "/glob"; + $node->{data} = $self->represent_glob($node->{value}); + }, + ); $schema->add_representer( class_matches => 1, @@ -370,6 +420,9 @@ elsif ($node->{reftype} eq 'CODE') { $node->{data} = $self->represent_code($node->{value}); } + elsif ($node->{reftype} eq 'GLOB') { + $node->{data} = $self->represent_glob($node->{value}); + } else { die "Reftype '$node->{reftype}' not implemented"; } @@ -402,6 +455,24 @@ return $qr; } +sub construct_glob { + my ($self, $list) = @_; + if (@$list % 2) { + die "Unexpected data in perl/glob construction"; + } + my %globdata = @$list; + my $name = delete $globdata{NAME} or die "Missing NAME in perl/glob"; + my $pkg = delete $globdata{PACKAGE}; + $pkg = 'main' unless defined $pkg; + my @allowed = qw(SCALAR ARRAY HASH CODE IO); + delete @globdata{ @allowed }; + if (my @keys = keys %globdata) { + die "Unexpected keys in perl/glob: @keys"; + } + no strict 'refs'; + return *{"${pkg}::$name"}; +} + sub construct_scalar { my ($self, $list) = @_; if (@$list != 2) { @@ -434,6 +505,32 @@ return $deparse->coderef2text($code); } + +my @stats = qw/ device inode mode links uid gid rdev size + atime mtime ctime blksize blocks /; +sub represent_glob { + my ($self, $glob) = @_; + my %glob; + for my $type (qw/ PACKAGE NAME SCALAR ARRAY HASH CODE IO /) { + my $value = *{ $glob }{ $type }; + if ($type eq 'SCALAR') { + $value = $$value; + } + elsif ($type eq 'IO') { + if (defined $value) { + undef $value; + $value->{stat} = {}; + if ($value->{fileno} = fileno(*{ $glob })) { + @{ $value->{stat} }{ @stats } = stat(*{ $glob }); + $value->{tell} = tell *{ $glob }; + } + } + } + $glob{ $type } = $value if defined $value; + } + return \%glob; +} + sub represent_regex { my ($self, $regex) = @_; $regex = "$regex"; @@ -492,9 +589,8 @@ when the object falls out of scope. L<File::Temp> is an example that can be exploitable and might remove arbitrary files. -Typeglobs are not implemented yet. Dumping code references is on by default, but -not loading (because that is easily exploitable since it's using string -C<eval>). +Dumping code references is on by default, but not loading (because that is +easily exploitable since it's using string C<eval>). =head2 Tag Styles diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/Tie/IxHash.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/Tie/IxHash.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/Tie/IxHash.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/Tie/IxHash.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::Tie::IxHash; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use base 'YAML::PP::Schema'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema/YAML1_1.pm new/YAML-PP-0.023/lib/YAML/PP/Schema/YAML1_1.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema/YAML1_1.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema/YAML1_1.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Schema::YAML1_1; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use YAML::PP::Schema::JSON qw/ represent_int represent_float represent_literal represent_bool diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Schema.pm new/YAML-PP-0.023/lib/YAML/PP/Schema.pm --- old/YAML-PP-0.022/lib/YAML/PP/Schema.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Schema.pm 2020-07-09 22:13:35.000000000 +0200 @@ -4,7 +4,7 @@ use B; use Module::Load qw//; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use YAML::PP::Common qw/ YAML_PLAIN_SCALAR_STYLE /; @@ -53,6 +53,7 @@ scalarref => undef, refref => undef, coderef => undef, + glob => undef, tied_equals => {}, ); my $self = bless { @@ -268,6 +269,12 @@ code => $args{code}, }; return; + } + if (defined(my $glob = $args{glob})) { + $representers->{glob} = { + code => $args{code}, + }; + return; } if (my $undef = $args{undefined}) { $representers->{undef} = $undef; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Type/MergeKey.pm new/YAML-PP-0.023/lib/YAML/PP/Type/MergeKey.pm --- old/YAML-PP-0.022/lib/YAML/PP/Type/MergeKey.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Type/MergeKey.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Type::MergeKey; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION sub new { my ($class) = @_; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Writer/File.pm new/YAML-PP-0.023/lib/YAML/PP/Writer/File.pm --- old/YAML-PP-0.022/lib/YAML/PP/Writer/File.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Writer/File.pm 2020-07-09 22:13:35.000000000 +0200 @@ -2,7 +2,7 @@ use warnings; package YAML::PP::Writer::File; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use Scalar::Util qw/ openhandle /; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP/Writer.pm new/YAML-PP-0.023/lib/YAML/PP/Writer.pm --- old/YAML-PP-0.022/lib/YAML/PP/Writer.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP/Writer.pm 2020-07-09 22:13:35.000000000 +0200 @@ -3,7 +3,7 @@ use warnings; package YAML::PP::Writer; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION sub output { return $_[0]->{output} } sub set_output { $_[0]->{output} = $_[1] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/lib/YAML/PP.pm new/YAML-PP-0.023/lib/YAML/PP.pm --- old/YAML-PP-0.022/lib/YAML/PP.pm 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/lib/YAML/PP.pm 2020-07-09 22:13:35.000000000 +0200 @@ -3,7 +3,7 @@ use warnings; package YAML::PP; -our $VERSION = '0.022'; # VERSION +our $VERSION = '0.023'; # VERSION use YAML::PP::Schema; use YAML::PP::Schema::JSON; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/t/22.dump-bool.t new/YAML-PP-0.023/t/22.dump-bool.t --- old/YAML-PP-0.022/t/22.dump-bool.t 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/t/22.dump-bool.t 2020-07-09 22:13:35.000000000 +0200 @@ -9,15 +9,19 @@ my $exp_yaml = <<"EOM"; --- -bool false: false -bool true: true +false1: false +false2: false +true1: true +true2: true EOM SKIP: { skip "boolean not installed", 1 unless $boolean; my $data = { - "bool true" => boolean::true(), - "bool false" => boolean::false(), + "true1" => boolean::true(), + "false1" => boolean::false(), + "true2" => boolean::true(), + "false2" => boolean::false(), }; my $yppd = YAML::PP->new(boolean => 'boolean'); my $yaml = $yppd->dump_string($data); @@ -27,12 +31,50 @@ SKIP: { skip "JSON::PP not installed", 1 unless $json_pp; my $data = { - "bool true" => JSON::PP::true(), - "bool false" => JSON::PP::false(), + "true1" => JSON::PP::true(), + "false1" => JSON::PP::false(), + "true2" => JSON::PP::true(), + "false2" => JSON::PP::false(), }; my $yppd = YAML::PP->new(boolean => 'JSON::PP'); my $yaml = $yppd->dump_string($data); cmp_ok($yaml, 'eq', $exp_yaml, "JSON::PP::Boolean dump"); } +SKIP: { + skip "JSON::PP and boolean not installed", 1 unless ($json_pp and $boolean); + my $data = { + "true1" => boolean::true(), + "false1" => boolean::false(), + "true2" => JSON::PP::true(), + "false2" => JSON::PP::false(), + }; + + my $yppd = YAML::PP->new(boolean => 'JSON::PP', schema => [qw/ + Perl /]); + my $yaml = $yppd->dump_string($data); + my $exp_json_pp = <<'EOM'; +--- +false1: !perl/scalar:boolean + =: 0 +false2: false +true1: !perl/scalar:boolean + =: 1 +true2: true +EOM + cmp_ok($yaml, 'eq', $exp_json_pp, "JSON::PP::Boolean (no boolean) dump"); + + $yppd = YAML::PP->new(boolean => 'boolean', schema => [qw/ + Perl /]); + $yaml = $yppd->dump_string($data); + my $exp_boolean = <<'EOM'; +--- +false1: false +false2: !perl/scalar:JSON::PP::Boolean + =: 0 +true1: true +true2: !perl/scalar:JSON::PP::Boolean + =: 1 +EOM + cmp_ok($yaml, 'eq', $exp_boolean, "boolean (no JSON::PP::Boolean) dump"); +} + done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/t/31.schema.t new/YAML-PP-0.023/t/31.schema.t --- old/YAML-PP-0.022/t/31.schema.t 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/t/31.schema.t 2020-07-09 22:13:35.000000000 +0200 @@ -23,11 +23,15 @@ ); my $boolean = $jsonpp ? 'JSON::PP' : 'perl'; -my $failsafe = YAML::PP->new( boolean => $boolean, schema => [qw/ Failsafe /] ); -my $json = YAML::PP->new( boolean => $boolean, schema => [qw/ JSON /] ); -my $json_empty_null = YAML::PP->new( boolean => $boolean, schema => [qw/ JSON empty=null /] ); -my $core = YAML::PP->new( boolean => $boolean, schema => [qw/ Core /] ); -my $yaml11 = YAML::PP->new( boolean => $boolean, schema => [qw/ YAML1_1 /] ); +my %args = ( + boolean => $boolean, + header => 0, +); +my $failsafe = YAML::PP->new( %args, schema => [qw/ Failsafe /] ); +my $json = YAML::PP->new( %args, schema => [qw/ JSON /] ); +my $json_empty_null = YAML::PP->new( %args, schema => [qw/ JSON empty=null /] ); +my $core = YAML::PP->new( %args, schema => [qw/ Core /] ); +my $yaml11 = YAML::PP->new( %args, schema => [qw/ YAML1_1 /] ); subtest 'invalid-option' => sub { @@ -126,7 +130,7 @@ ok(!$is_str, "$label is not str"); unless ($func) { - cmp_ok($data, 'eq', $def{data}, "$label eq '$def{data}'"); + cmp_ok($data, '==', $def{data}, "$label == '$def{data}'"); } } elsif ($type eq 'float' or $type eq 'inf' or $type eq 'nan') { @@ -136,7 +140,7 @@ } unless ($func) { - cmp_ok($data, '==', $def{data}, "$label eq '$def{data}'"); + cmp_ok(sprintf("%.2f", $data), '==', $def{data}, "$label == '$def{data}'"); } } elsif ($type eq 'bool' or $type eq 'null') { @@ -147,7 +151,6 @@ unless ($inf_broken) { my $yaml_dump = $yp->dump_string($data_orig); - $yaml_dump =~ s/^--- //; $yaml_dump =~ s/\n\z//; cmp_ok($yaml_dump, 'eq', $def{dump}, "$label-dump as expected"); } @@ -164,7 +167,7 @@ my $yp = $loaders{ $name }; my $yaml = $yp->dump_string($x); chomp $yaml; - cmp_ok($yaml, 'eq', '--- 25.1', "$name: IV and PV"); + cmp_ok($yaml, 'eq', '25.1', "$name: IV and PV"); } }; @@ -179,7 +182,7 @@ my $yp = $loaders{ $name }; my $yaml = $yp->dump_string($x); chomp $yaml; - cmp_ok($yaml, 'eq', '--- 19x', "$name: NV and PV"); + cmp_ok($yaml, 'eq', '19x', "$name: NV and PV"); } }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/t/35.highlight.t new/YAML-PP-0.023/t/35.highlight.t --- old/YAML-PP-0.022/t/35.highlight.t 2020-05-04 17:41:40.000000000 +0200 +++ new/YAML-PP-0.023/t/35.highlight.t 2020-07-09 22:13:35.000000000 +0200 @@ -48,8 +48,8 @@ my $color = eval "use Term::ANSIColor 4.02; 1"; # older versions of Term::ANSIColor didn't have grey12 if ($color) { - my $highlighted = YAML::PP::Highlight::Dump("foo: bar\n"); - my $exp_highlighted = "\e[1m---\e[0m \e[1;33m|\e[0m\n\e[37;48;5;235m \e[0m\e[33mfoo: bar\e[0m\n\n"; + my $highlighted = YAML::PP::Highlight::Dump({ foo => 'bar' }); + my $exp_highlighted = "\e[1m---\e[0m\n\e[94mfoo\e[0m\e[1;35m:\e[0m bar\n"; cmp_ok($highlighted, 'eq', $exp_highlighted, "YAML::PP::Highlight::Dump()"); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/t/53.customtag-alias.t new/YAML-PP-0.023/t/53.customtag-alias.t --- old/YAML-PP-0.022/t/53.customtag-alias.t 1970-01-01 01:00:00.000000000 +0100 +++ new/YAML-PP-0.023/t/53.customtag-alias.t 2020-07-09 22:13:35.000000000 +0200 @@ -0,0 +1,78 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Deep; +use FindBin '$Bin'; +use YAML::PP; + + +subtest 'join-tag' => sub { + my $yp = YAML::PP->new; + $yp->schema->add_sequence_resolver( + tag => '!join', + on_create => sub { return '' }, + on_data => sub { + my ($constructor, $data, $list) = @_; + my $join = shift @$list; + $$data .= join $join, @$list; + }, + ); + my $yaml = <<'EOM'; +--- +name: &name YAML +string: &what !join [ ' ', *name, Ain't, Markup, Language ] +alias: *what +EOM + my $string = "YAML Ain't Markup Language"; + my $expected = { + name => 'YAML', + string => $string, + alias => $string, + }; + my ($data) = $yp->load_string($yaml); + is_deeply($data, $expected, 'Loaded data as expected'); +}; + +subtest 'inherit-tag' => sub { + my $yp = YAML::PP->new; + $yp->schema->add_mapping_resolver( + tag => '!inherit', +# on_create => sub { return '' }, + on_data => sub { + my ($constructor, $data, $list) = @_; + for my $item (@$list) { + %$$data = (%$$data, %$item); + } + }, + ); + my $yaml = <<'EOM'; +--- +parent: &parent + a: A + b: B +child: &child !inherit + *parent : + a: new A + c: C +twin: *child +EOM + my $string = "YAML Ain't Markup Language"; + my $child = { + a => 'new A', + b => 'B', + c => 'C', + }; + my $expected = { + parent => { + a => 'A', + b => 'B', + }, + child => $child, + twin => $child, + }; + my ($data) = $yp->load_string($yaml); + is_deeply($data, $expected, 'Loaded data as expected'); +}; + +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/YAML-PP-0.022/t/54.glob.t new/YAML-PP-0.023/t/54.glob.t --- old/YAML-PP-0.022/t/54.glob.t 1970-01-01 01:00:00.000000000 +0100 +++ new/YAML-PP-0.023/t/54.glob.t 2020-07-09 22:13:35.000000000 +0200 @@ -0,0 +1,179 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use FindBin '$Bin'; +use Data::Dumper; +use Test::Deep qw/ cmp_deeply /; +use IO::File; +use YAML::PP; +use Scalar::Util qw/ blessed reftype /; + +our $var = "Hola"; +our @var = (3, 14, 15); +our %var = (pi => '3.1415'); +my $stdin = \*DATA, +my $fileno = fileno DATA; + +my $yp = YAML::PP->new( + schema => [qw/ + Perl /], +); + +my %tests = ( + simple => { + in => <<'EOM', +--- !perl/glob +ARRAY: +- 3 +- 14 +- 15 +HASH: + pi: '3.1415' +NAME: var +PACKAGE: main +SCALAR: Hola +EOM + name => '*main::var', + value => 'Hola', + types => { + SCALAR => 'Hola', + ARRAY => [ 3, 14, 15 ], + HASH => { pi => '3.1415' }, + }, + }, + blessed => { + in => <<'EOM', +--- !perl/glob:Foo +ARRAY: +- 3 +- 14 +- 15 +HASH: + pi: '3.1415' +NAME: var +PACKAGE: main +SCALAR: Hola +EOM + name => '*main::var', + class => 'Foo', + value => 'Hola', + types => { + SCALAR => 'Hola', + ARRAY => [ 3, 14, 15 ], + HASH => { pi => '3.1415' }, + }, + }, + io => { + in => <<"EOM", +--- !perl/glob +IO: + fileno: $fileno + stat: {} +NAME: DATA +PACKAGE: main +EOM + name => '*main::DATA', + types => { + IO => $fileno, + }, + }, + blessed_io => { + in => <<"EOM", +--- !perl/glob:Foo +IO: + fileno: $fileno + stat: {} +NAME: DATA +PACKAGE: main +EOM + name => '*main::DATA', + class => 'Foo', + types => { + IO => $fileno, + }, + }, +); + +subtest valid => sub { + for my $key (sort keys %tests) { + my $test = $tests{ $key }; + my $name = $test->{name}; + my $class = $test->{class} || ''; + note "============ $key $name"; + my $input = $test->{in}; + my $data = $yp->load_string($input); + my $glob = *{$data}; + if ($class) { + my $reftype = reftype($data); + is($reftype, 'GLOB', "$key - $name - ($class) reftype is glob"); + is(ref $data, $class, "$key - $name - Class equals '$class'"); + } + else { + my $reftype = reftype(\$data); + is($reftype, 'GLOB', "$key - $name - reftype is glob"); + } + is("$glob", $name, "$key - $name - Glob name"); + my $types = $test->{types}; + for my $type (sort keys %$types) { + my $exp = $types->{ $type }; + my $value; + my $glob = *{$data}{ $type }; + if ($type eq 'SCALAR') { + $value = $$glob; + } + elsif ($type eq 'ARRAY') { + $value = [ @$glob ]; + } + elsif ($type eq 'HASH') { + $value = { %$glob }; + } + elsif ($type eq 'IO') { + $value = fileno $glob; + } + cmp_deeply($value, $exp, "$key - $name - $type - Data equal"); + } + + my $dump = $yp->dump_string($data); + if ($key =~ m/io/) { + $dump =~ s/^ [a-z]+: \S+\n//mg; + $dump =~ s/^ tell: \S+\n//m; + $dump =~ s/stat:$/stat: \{\}/m; + } + is($dump, $input, "$key - $name - Dump equals input"); + } +}; + +subtest ioscalar => sub { + my $fh = IO::File->new("< $Bin/54.glob.t"); + my $dump = $yp->dump_string($fh); + my $fn = $fh->fileno; + like $dump, qr{--- !perl/glob:IO::File}, "IO::Scalar correctly dumped as blessed per/glob"; + like $dump, qr{fileno: $fn$}m, "IO::Scalar fileno correct"; +}; + +my @error = ( + [ <<'EOM', qr{Unexpected keys in perl/glob}], +--- !perl/glob +NAME: var +this: should not be here +EOM + [ <<'EOM', qr{Missing NAME in perl/glob}], +--- !perl/glob +name: invalid +EOM +); +subtest error => sub { + for my $item (@error) { + my ($input, $qr) = @$item; + my $data = eval { + $yp->load_string($input); + }; + my $err = $@; + like $err, $qr, "Invalid glob - error matches $qr"; + } +}; + +done_testing; + +__DATA__ +dummy
