summaryrefslogtreecommitdiff
path: root/lib/URI/Escape.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/URI/Escape.pm')
-rw-r--r--lib/URI/Escape.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/URI/Escape.pm b/lib/URI/Escape.pm
index d434488..cec5d56 100644
--- a/lib/URI/Escape.pm
+++ b/lib/URI/Escape.pm
@@ -163,7 +163,14 @@ sub uri_escape {
if (defined $patn){
unless (exists $subst{$patn}) {
# Because we can't compile the regex we fake it with a cached sub
- (my $tmp = $patn) =~ s,/,\\/,g;
+ my @parts = $patn =~ m/(
+ (?: ^ \^? -? )
+ | (?: .-. )
+ | (?: \[:[^:]+:\] )
+ | .
+ )/gx;
+
+ my $tmp = join '', shift @parts, map { length > 1 ? $_ : quotemeta } @parts;
eval "\$subst{\$patn} = sub {\$_[0] =~ s/([$tmp])/\$escapes{\$1} || _fail_hi(\$1)/ge; }";
Carp::croak("uri_escape: $@") if $@;
}