]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: fix esc_param
authorGiuseppe Bilotta <redacted>
Tue, 13 Oct 2009 19:51:36 +0000 (21:51 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:39 +0000 (00:50 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 924d62614a007781297450007174f389b2822b3b929ca2da921a1d54a613b4aa..8347d07e1c21ae1a5cd5522bbfe96549dacc6eb9324b35b56637237341a15788 100755 (executable)
@@ -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;
 }
This page took 0.335566 seconds and 4 git commands to generate.