Pod::Html: fix anchorify() whitespace stripping

This method had the line

    $anchor =~ s/^\s+//; s/\s+$//;      # Strip white space.

where leading space was stripped from $anchor, but trailing space
was being attempted to be stripped from $_ instead, giving rise to
a bunch of warnings like:

    Use of uninitialized value $_ in substitution (s///)
        at lib/Pod/Html/Util.pm line 253.

during 'make install.html'
This commit is contained in:
David Mitchell 2025-12-23 11:28:37 +00:00
parent 3f6ffa0335
commit 65c55e8ba6
3 changed files with 6 additions and 4 deletions

View File

@ -2,7 +2,7 @@ package Pod::Html;
use strict;
use Exporter 'import';
our $VERSION = 1.35;
our $VERSION = 1.36;
$VERSION = eval $VERSION;
our @EXPORT = qw(pod2html);

View File

@ -2,7 +2,7 @@ package Pod::Html::Util;
use strict;
use Exporter 'import';
our $VERSION = 1.35; # Please keep in synch with lib/Pod/Html.pm
our $VERSION = 1.36; # Please keep in synch with lib/Pod/Html.pm
$VERSION = eval $VERSION;
our @EXPORT_OK = qw(
anchorify
@ -250,7 +250,9 @@ sub anchorify {
$anchor =~ s/"/_/g; # Replace double quotes with underscores
$anchor =~ s/_$//; # ... but strip any final underscore
$anchor =~ s/[<>&']//g; # Strip the remaining HTML special characters
$anchor =~ s/^\s+//; s/\s+$//; # Strip white space.
$anchor =~ s/^\s+//; # Strip white space.
$anchor =~ s/\s+$//;
$anchor =~ s/^([^a-zA-Z]+)$/pod$1/; # Prepend "pod" if no valid chars.
$anchor =~ s/^[^a-zA-Z]+//; # First char must be a letter.
$anchor =~ s/[^-a-zA-Z0-9_:.]+/-/g; # All other chars must be valid.

View File

@ -2,7 +2,7 @@ package Testing;
use 5.10.0;
use warnings;
use Exporter 'import';
our $VERSION = 1.35; # Let's keep this same as lib/Pod/Html.pm
our $VERSION = 1.36; # Let's keep this same as lib/Pod/Html.pm
$VERSION = eval $VERSION;
our @EXPORT_OK = qw(
setup_testing_dir