From e2c089dc3506418fa522284b81914a124f14a574 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sun, 2 Feb 2025 16:02:45 +0100 Subject: [PATCH] when searching for a package line, allow apostrophes in the module name When searching for a package line to see if it is intentionally hidden, we are matching against the specific module that we are using. But the name that exists in the code could include apostrophes instead of double colons, while the recorded module name is normalized to use colons. Construct a regex to allow matching the module name but with apostrophe package separators. --- lib/MetaCPAN/Document/Module.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/MetaCPAN/Document/Module.pm b/lib/MetaCPAN/Document/Module.pm index bf866e88d..3f1fc5358 100644 --- a/lib/MetaCPAN/Document/Module.pm +++ b/lib/MetaCPAN/Document/Module.pm @@ -114,7 +114,8 @@ my $bom sub hide_from_pause { my ( $self, $content, $file_name ) = @_; return 0 if defined($file_name) && $file_name =~ m{\.pm\.PL\z}; - my $pkg = $self->name; + my $pkg = $self->name; + my $pkg_match = join q[(?:::|')], map quotemeta, split m{::}, $pkg; # This regexp is *almost* the same as $PKG_REGEXP in Module::Metadata. # [b] We need to allow/ignore a possible BOM since we read in binary mode. @@ -128,7 +129,7 @@ sub hide_from_pause { [\h\{;]* # intro chars on a line [s] package # the word 'package' \h+ # whitespace [s] - (\Q$pkg\E) # a package name [p] + ($pkg_match) # the package name [p] (\h+ v?[0-9._]+)? # optional version number (preceded by whitespace) [v] \h* # optional whitesapce [s] [;\{] # semicolon line terminator or block start