Skip to content

Commit cf70670

Browse files
committed
Allow unknown tags by default again (broke other code)
The previous change about forbidding unknown tags by default was accidentally released as a regular release, and also I didn't think at that point that many other libraries / tests would depend on the old behaviour.
1 parent 5aa8c69 commit cf70670

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

bin/yamlpp-load

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ GetOptions(
1515
'cyclic' => \my $cyclic,
1616
'duplicate-keys' => \my $duplicate_keys,
1717
'merge' => \my $merge,
18-
'catchall' => \my $catchall,
18+
#'catchall' => \my $catchall,
1919
'require-footer' => \my $require_footer,
2020
'perl' => \my $perl,
2121
'module|M=s' => \my $module,
@@ -35,9 +35,9 @@ if ($merge) {
3535
if ($perl) {
3636
push @schema, 'Perl';
3737
}
38-
if ($catchall) {
39-
push @schema, 'Catchall';
40-
}
38+
#if ($catchall) {
39+
# push @schema, 'Catchall';
40+
#}
4141

4242
my ($file) = @ARGV;
4343
my $yaml;
@@ -143,13 +143,13 @@ Options:
143143
--cyclic Allow cyclic references
144144
--duplicate-keys Allow duplicate keys
145145
--merge Enable loading merge keys '<<'
146-
--catchall Ignore any unknown tags
147146
--require-footer Require '...' and the end of each document
148147
--perl Enable loading perl types and objects (use only
149148
on trusted input!)
150149
--module -M YAML::PP (default), YAML, YAML::PP::LibYAML,
151150
YAML::Syck, YAML::Tiny, YAML::XS, YAML::PP::Ref
152151
--yaml-version= '1.2' (default), '1.1', '1.2,1.1', '1.1,1.2'
153152
EOM
153+
#--catchall Ignore any unknown tags
154154
exit $rc;
155155
}

bin/yamlpp-load-dump

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ GetOptions(
2121
'header!' => \my $header,
2222
'footer!' => \my $footer,
2323
'merge' => \my $merge,
24-
'catchall' => \my $catchall,
24+
#'catchall' => \my $catchall,
2525
'require-footer' => \my $require_footer,
2626
'perl' => \my $perl,
2727
'preserve|P=s' => \my $preserve,
@@ -52,9 +52,9 @@ if ($merge) {
5252
if ($perl) {
5353
push @schema, 'Perl';
5454
}
55-
if ($catchall) {
56-
push @schema, 'Catchall';
57-
}
55+
#if ($catchall) {
56+
# push @schema, 'Catchall';
57+
#}
5858

5959
my $preserve_order = 1;
6060
if (defined $preserve) {
@@ -293,7 +293,6 @@ Options:
293293
--[no-]header Print '---' (default)
294294
--[no-]footer Print '...'
295295
--merge Enable loading merge keys '<<'
296-
--catchall Ignore any unknown tags
297296
--require-footer Require '...' and the end of each document
298297
--perl Enable loading perl types and objects (use only
299298
on trusted input!)
@@ -310,5 +309,6 @@ Options:
310309
--include-absolute Allow absolute paths and ../../../ in includes (use
311310
only on trusted input!)
312311
EOM
312+
# --catchall Ignore any unknown tags
313313
exit $rc;
314314
}

lib/YAML/PP.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,9 +1060,10 @@ YAML 1.1 merge keys for mappings
10601060
10611061
=item L<YAML::PP::Schema::Catchall>
10621062
1063-
Adding this allows (and ignores) all unknown tags, like
1063+
Experimental.
10641064
1065-
key: !something value
1065+
It was accidentally added in 0.38.1, and unknown tags forbidden.
1066+
This was reverted in 0.39.0
10661067
10671068
By default they will result in an error.
10681069

lib/YAML/PP/Schema.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ sub load_scalar {
320320
}
321321
}
322322
}
323-
unless ($res) {
324-
croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags";
325-
}
323+
#unless ($res) {
324+
# croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags";
325+
#}
326326
}
327327
else {
328328
$res = $resolvers->{value};
@@ -383,7 +383,7 @@ sub create_sequence {
383383
}
384384
}
385385
}
386-
croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags";
386+
#croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags";
387387
}
388388

389389
return ($data, $on_data);
@@ -414,7 +414,7 @@ sub create_mapping {
414414
}
415415
}
416416
}
417-
croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags";
417+
#croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags";
418418
}
419419

420420
return ($data, $on_data);

t/37.schema-catchall.t

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ use Data::Dumper;
77
use Scalar::Util ();
88
use YAML::PP;
99

10-
my $yp = YAML::PP->new(
11-
schema => [qw/ JSON /],
12-
);
10+
my $yp = YAML::PP->new();
1311
my $catch = YAML::PP->new(
14-
schema => [qw/ JSON Catchall /],
12+
schema => [qw/ + Catchall /],
1513
);
1614

1715
my $yaml = <<'EOM';
1816
- !foo null
1917
EOM
2018

19+
pass "dummy";
20+
done_testing;
21+
__END__
2122
my $data = eval { $yp->load_string($yaml) };
2223
my $err = $@;
2324
like $err, qr{Unknown tag '!foo'. Use schema 'Catchall'}, "unknoen tags are fatal by default";

0 commit comments

Comments
 (0)