diff --git a/lib/MetaCPAN/Document/File.pm b/lib/MetaCPAN/Document/File.pm index ccf94edf9..091f3579f 100644 --- a/lib/MetaCPAN/Document/File.pm +++ b/lib/MetaCPAN/Document/File.pm @@ -687,6 +687,10 @@ Expects a C<$meta> parameter which is an instance of L. For each package (L) in the file and based on L it is decided, whether the module should have a true L attribute. +If there are any packages with leading underscores, the module gets a false +L attribute, because PAUSE doesn't allow this kind of name for packages +(https://github.com/andk/pause/blob/master/lib/PAUSE/pmfile.pm#L249). + If L returns true but the package declaration uses the I hack, the L property is set to false. @@ -705,6 +709,10 @@ sub set_indexed { my ( $self, $meta ) = @_; foreach my $mod ( @{ $self->module } ) { + if ( $mod->name !~ /^[A-Za-z]/ ) { + $mod->indexed(0); + next; + } $mod->indexed( $meta->should_index_package( $mod->name ) ? $mod->hide_from_pause( ${ $self->content }, $self->name ) diff --git a/t/document/file.t b/t/document/file.t index 032832049..26a301158 100644 --- a/t/document/file.t +++ b/t/document/file.t @@ -207,6 +207,11 @@ END }; }; +subtest 'Packages starting with underscore are not indexed' => sub { + my $file = new_file_doc( module => { name => '_Package::Foo' } ); + is( $file->module->[0]->indexed, 0, 'Package is not indexed' ); +}; + subtest 'pod name/package mismatch' => sub { my $content = <<'END'; package