diff options
Diffstat (limited to 'Master/tlpkg/tlperl/lib/URI/Escape.pm')
-rw-r--r-- | Master/tlpkg/tlperl/lib/URI/Escape.pm | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Master/tlpkg/tlperl/lib/URI/Escape.pm b/Master/tlpkg/tlperl/lib/URI/Escape.pm index e09d76acc48..547535ea801 100644 --- a/Master/tlpkg/tlperl/lib/URI/Escape.pm +++ b/Master/tlpkg/tlperl/lib/URI/Escape.pm @@ -1,5 +1,7 @@ package URI::Escape; + use strict; +use warnings; =head1 NAME @@ -135,8 +137,7 @@ it under the same terms as Perl itself. =cut -require Exporter; -our @ISA = qw(Exporter); +use Exporter 'import'; our %escapes; our @EXPORT = qw(uri_escape uri_unescape uri_escape_utf8); our @EXPORT_OK = qw(%escapes); @@ -201,8 +202,19 @@ sub uri_unescape { $str; } +# XXX FIXME escape_char is buggy as it assigns meaning to the string's storage format. sub escape_char { - return join '', @URI::Escape::escapes{$_[0] =~ /(\C)/g}; + # Old versions of utf8::is_utf8() didn't properly handle magical vars (e.g. $1). + # The following forces a fetch to occur beforehand. + my $dummy = substr($_[0], 0, 0); + + if (utf8::is_utf8($_[0])) { + my $s = shift; + utf8::encode($s); + unshift(@_, $s); + } + + return join '', @URI::Escape::escapes{split //, $_[0]}; } 1; |