summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rwxr-xr-xPorting/Maintainers.pl2
-rw-r--r--cpan/Parse-CPAN-Meta/lib/Parse/CPAN/Meta.pm14
-rw-r--r--cpan/Parse-CPAN-Meta/t/02_api.t19
-rw-r--r--cpan/Parse-CPAN-Meta/t/03_functions.t10
-rw-r--r--cpan/Parse-CPAN-Meta/t/04_export.t10
-rw-r--r--cpan/Parse-CPAN-Meta/t/05_errors.t10
-rw-r--r--cpan/Parse-CPAN-Meta/t/data/BadMETA.yml24
-rw-r--r--cpan/Parse-CPAN-Meta/t/lib/Parse/CPAN/Meta/Test.pm6
9 files changed, 43 insertions, 53 deletions
diff --git a/MANIFEST b/MANIFEST
index e5dab219c3..3c561b7fb3 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1731,6 +1731,7 @@ cpan/Parse-CPAN-Meta/t/02_api.t
cpan/Parse-CPAN-Meta/t/03_functions.t
cpan/Parse-CPAN-Meta/t/04_export.t
cpan/Parse-CPAN-Meta/t/05_errors.t
+cpan/Parse-CPAN-Meta/t/data/BadMETA.yml
cpan/Parse-CPAN-Meta/t/data/META-VR.json
cpan/Parse-CPAN-Meta/t/data/META-VR.yml
cpan/Parse-CPAN-Meta/t/lib/Parse/CPAN/Meta/Test.pm
diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
index 2e782ac420..658a731f7c 100755
--- a/Porting/Maintainers.pl
+++ b/Porting/Maintainers.pl
@@ -876,7 +876,7 @@ use File::Glob qw(:case);
},
'Parse::CPAN::Meta' => {
- 'DISTRIBUTION' => 'DAGOLDEN/Parse-CPAN-Meta-1.4410.tar.gz',
+ 'DISTRIBUTION' => 'DAGOLDEN/Parse-CPAN-Meta-1.4412.tar.gz',
'FILES' => q[cpan/Parse-CPAN-Meta],
'EXCLUDED' => [
qw(t/00-compile.t),
diff --git a/cpan/Parse-CPAN-Meta/lib/Parse/CPAN/Meta.pm b/cpan/Parse-CPAN-Meta/lib/Parse/CPAN/Meta.pm
index 8b3322908d..1b63d89196 100644
--- a/cpan/Parse-CPAN-Meta/lib/Parse/CPAN/Meta.pm
+++ b/cpan/Parse-CPAN-Meta/lib/Parse/CPAN/Meta.pm
@@ -2,7 +2,7 @@ use 5.008001;
use strict;
package Parse::CPAN::Meta;
# ABSTRACT: Parse META.yml and META.json CPAN metadata files
-our $VERSION = '1.4410'; # VERSION
+our $VERSION = '1.4412'; # VERSION
use Exporter;
use Carp 'croak';
@@ -70,7 +70,10 @@ sub json_backend {
}
sub _slurp {
- open my $fh, "<:utf8", "$_[0]" ## no critic
+ require Encode;
+ require PerlIO::encoding;
+ local $PerlIO::encoding::fallback = Encode::PERLQQ()|Encode::STOP_AT_PARTIAL();
+ open my $fh, "<:encoding(UTF-8)", "$_[0]" ## no critic
or die "can't open $_[0] for reading: $!";
return do { local $/; <$fh> };
}
@@ -93,10 +96,7 @@ sub _can_load {
# Kept for backwards compatibility only
# Create an object from a file
sub LoadFile ($) {
- require CPAN::Meta::YAML;
- my $object = eval { CPAN::Meta::YAML::LoadFile(shift) };
- croak $@ if $@;
- return $object;
+ return Load(_slurp(shift));
}
# Parse a document from a string.
@@ -121,7 +121,7 @@ Parse::CPAN::Meta - Parse META.yml and META.json CPAN metadata files
=head1 VERSION
-version 1.4410
+version 1.4412
=head1 SYNOPSIS
diff --git a/cpan/Parse-CPAN-Meta/t/02_api.t b/cpan/Parse-CPAN-Meta/t/02_api.t
index e9c62e3f92..517f7fe120 100644
--- a/cpan/Parse-CPAN-Meta/t/02_api.t
+++ b/cpan/Parse-CPAN-Meta/t/02_api.t
@@ -5,22 +5,13 @@ delete $ENV{PERL_JSON_BACKEND};
# Testing of a known-bad file from an editor
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib/';
- }
-}
-
use strict;
BEGIN {
$| = 1;
$^W = 1;
}
+use lib 't/lib';
use File::Spec::Functions ':ALL';
use Parse::CPAN::Meta;
use Parse::CPAN::Meta::Test;
@@ -78,6 +69,14 @@ my $meta_yaml = catfile( test_data_directory(), 'META-VR.yml' );
is_deeply($from_yaml, $want, "load from YAML str results in expected data");
}
+{
+ local $ENV{PERL_YAML_BACKEND}; # ensure we get CPAN::META::YAML
+
+ my @yaml = Parse::CPAN::Meta::LoadFile( 't/data/BadMETA.yml' );
+ is($yaml[0]{author}[0], 'Olivier Mengu\xE9', "Bad UTF-8 is replaced");
+}
+
+
SKIP: {
skip "YAML module not installed", 2
unless eval "require YAML; 1";
diff --git a/cpan/Parse-CPAN-Meta/t/03_functions.t b/cpan/Parse-CPAN-Meta/t/03_functions.t
index a5deff9585..5f6d1d8732 100644
--- a/cpan/Parse-CPAN-Meta/t/03_functions.t
+++ b/cpan/Parse-CPAN-Meta/t/03_functions.t
@@ -5,16 +5,6 @@ delete $ENV{PERL_JSON_BACKEND};
# Testing of basic document structures
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib/';
- }
-}
-
use strict;
BEGIN {
$| = 1;
diff --git a/cpan/Parse-CPAN-Meta/t/04_export.t b/cpan/Parse-CPAN-Meta/t/04_export.t
index 1a85d4e9aa..b4766aa558 100644
--- a/cpan/Parse-CPAN-Meta/t/04_export.t
+++ b/cpan/Parse-CPAN-Meta/t/04_export.t
@@ -5,16 +5,6 @@ delete $ENV{PERL_JSON_BACKEND};
# Testing of basic document structures
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib/';
- }
-}
-
use strict;
BEGIN {
$| = 1;
diff --git a/cpan/Parse-CPAN-Meta/t/05_errors.t b/cpan/Parse-CPAN-Meta/t/05_errors.t
index 9217500d69..671d73bce0 100644
--- a/cpan/Parse-CPAN-Meta/t/05_errors.t
+++ b/cpan/Parse-CPAN-Meta/t/05_errors.t
@@ -5,16 +5,6 @@ delete $ENV{PERL_JSON_BACKEND};
# Testing of basic document structures
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib/';
- }
-}
-
use strict;
BEGIN {
$| = 1;
diff --git a/cpan/Parse-CPAN-Meta/t/data/BadMETA.yml b/cpan/Parse-CPAN-Meta/t/data/BadMETA.yml
new file mode 100644
index 0000000000..79fece368c
--- /dev/null
+++ b/cpan/Parse-CPAN-Meta/t/data/BadMETA.yml
@@ -0,0 +1,24 @@
+---
+abstract: ~
+author:
+ - 'Olivier Mengué'
+build_requires:
+ ExtUtils::MakeMaker: 6.36
+configure_requires:
+ ExtUtils::MakeMaker: 6.36
+distribution_type: module
+dynamic_config: 1
+generated_by: 'Module::Install version 1.06'
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
+name: Foo
+no_index:
+ directory:
+ - inc
+requires:
+ perl: 5.005
+resources:
+ license: http://dev.perl.org/licenses/
+version: 0.01
diff --git a/cpan/Parse-CPAN-Meta/t/lib/Parse/CPAN/Meta/Test.pm b/cpan/Parse-CPAN-Meta/t/lib/Parse/CPAN/Meta/Test.pm
index 3e86911f07..46024db5d7 100644
--- a/cpan/Parse-CPAN-Meta/t/lib/Parse/CPAN/Meta/Test.pm
+++ b/cpan/Parse-CPAN-Meta/t/lib/Parse/CPAN/Meta/Test.pm
@@ -16,11 +16,7 @@ BEGIN {
}
sub test_data_directory {
- return(
- $ENV{PERL_CORE}
- ? File::Spec->catdir(File::Spec->updir, qw(lib Parse CPAN Meta t data))
- : File::Spec->catdir(qw(t data))
- );
+ return( File::Spec->catdir(qw(t data)) );
}
# 22 tests per call to yaml_ok