IPv6 addresses are hexadecimals and colons inside brackets, so
add some DWIM-ery to ensure we don't attempt to treat addresses
like "http://[dead:beef]/foo/" as a glob.
my $p = '';
my $in_bracket = 0;
my $qm = 0;
+ my $schema_host_port = '';
+
+ # don't glob URL-looking things that look like IPv6
+ if ($re =~ s!\A([a-z0-9\+]+://\[[a-f0-9\:]+\](?::[0-9]+)?/)!!i) {
+ $schema_host_port = quotemeta $1; # "http://[::1]:1234"
+ }
my $changes = ($re =~ s!(.)!
$re_map{$p eq '\\' ? '' : do {
if ($1 eq '[') { ++$in_bracket }
(my $in_braces = $2) =~ tr!,!|!;
$1."($in_braces)";
/sge);
- ($changes - $qm) ? $re : undef;
+ ($changes - $qm) ? $schema_host_port.$re : undef;
}
# get canonicalized externals list matching $loc
is($canon->('/ALL/CAPS'), '/ALL/CAPS', 'caps preserved');
my $glob2re = $cls->can('glob2re');
+is($glob2re->('http://[::1]:1234/foo/'), undef, 'IPv6 URL not globbed');
is($glob2re->('foo'), undef, 'plain string unchanged');
is_deeply($glob2re->('[f-o]'), '[f-o]' , 'range accepted');
is_deeply($glob2re->('*'), '[^/]*?' , 'wildcard accepted');