From: Giuseppe Bilotta Date: Tue, 13 Oct 2009 19:51:36 +0000 (+0200) Subject: gitweb: fix esc_param X-Git-Url: https://git.ladys.computer/Gitweb/commitdiff_plain/2d23087538058461130c845b6268b1a3f3107da44464a8d95c3852a6e6d8f503 gitweb: fix esc_param The custom CGI escaping done in esc_param failed to escape UTF-8 properly. Fix by using CGI::escape on each sequence of matched characters instead of sprintf()ing a custom escaping for each byte. Additionally, the space -> + escape was being escaped due to greedy matching on the first substitution. Fix by adding space to the list of characters not handled on the first substitution. Finally, remove an unnecessary escaping of the + sign. Signed-off-by: Giuseppe Bilotta Signed-off-by: Junio C Hamano --- diff --git a/gitweb.perl b/gitweb.perl index 924d626..8347d07 100755 --- a/gitweb.perl +++ b/gitweb.perl @@ -1117,8 +1117,7 @@ sub to_utf8 { # correct, but quoted slashes look too horrible in bookmarks sub esc_param { my $str = shift; - $str =~ s/([^A-Za-z0-9\-_.~()\/:@])/sprintf("%%%02X", ord($1))/eg; - $str =~ s/\+/%2B/g; + $str =~ s/([^A-Za-z0-9\-_.~()\/:@ ]+)/CGI::escape($1)/eg; $str =~ s/ /\+/g; return $str; }