Skip to content

Commit bc0c585

Browse files
committed
Make sure to replace forwardslash on unix systems filenames
Also make sure to check for the proper characters in htmlify.p6
1 parent cbbd4bc commit bc0c585

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

htmlify.p6

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ use Perl6::TypeGraph::Viz;
3333
use Pod::Convenience;
3434
use Pod::Htmlify;
3535
use OO::Monitors;
36-
36+
# Don't include backslash in Win or forwardslash on Unix because they are used
37+
# as directory seperators. These are handled in lib/Pod/Htmlify.pm6
38+
my \badchars-ntfs = Qw[ / ? < > : * | " ];
39+
my \badchars-unix = Qw[ ];
40+
my \badchars = $*DISTRO.is-win ?? badchars-ntfs !! badchars-unix;
3741
{
3842
my monitor PathChecker {
3943
has %!seen-paths;
4044
method check($path) {
41-
note "$path got badchar" if $path.contains(any(qw[\ % ? & = # + " ' : ~ < >]));
45+
note "$path got badchar" if $path.contains(any(badchars));
4246
note "$path got empty filename" if $path.split('/')[*-1] eq '.html';
4347
note "duplicated path $path" if %!seen-paths{$path}:exists;
4448
%!seen-paths{$path}++;

lib/Pod/Htmlify.pm6

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ sub url-munge($_) is export {
1414
return $_;
1515
}
1616

17-
constant badchars = qw[$ / \ . % ? & = # + " ' ~ < > |]
18-
~ (':' if $*DISTRO.is-win);
17+
my \badchars-ntfs = Qw[ / ? < > \ : * | " ];
18+
my \badchars-unix = Qw[ / ];
19+
my \badchars = $*DISTRO.is-win ?? badchars-ntfs !! badchars-unix;
1920
my \goodnames = badchars.map: '$' ~ *.uniname.subst(' ', '_', :g);
20-
constant length = badchars.elems;
21+
my \length = badchars.elems;
2122

2223
sub escape-filename($s is copy) is export {
2324
# return $s if $s ~~ m{^ <[a..z]>+ '://'}; # bail on external links

0 commit comments

Comments
 (0)