diff options
author | Eric Wong <e@80x24.org> | 2021-02-25 05:37:17 +0600 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-02-25 09:47:34 +0000 |
commit | 335eff473d58fa2d9431cd119b8cc8ce855e7c72 (patch) | |
tree | a4f6dd4c98f233fbb2c3664358889fbc5f1c0268 /lib/PublicInbox | |
parent | ab32ba9e13b0fe83314b76a481439a39a88a3359 (diff) | |
download | public-inbox-335eff473d58fa2d9431cd119b8cc8ce855e7c72.tar.gz |
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.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/LeiExternal.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiExternal.pm b/lib/PublicInbox/LeiExternal.pm index 0cc84cca..47791d4e 100644 --- a/lib/PublicInbox/LeiExternal.pm +++ b/lib/PublicInbox/LeiExternal.pm @@ -54,6 +54,12 @@ sub glob2re { 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 } @@ -69,7 +75,7 @@ sub glob2re { (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 |