Skip to content

Commit 452e225

Browse files
Oblomovgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6ff9ae9 commit 452e225

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

gitweb/gitweb.perl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,7 @@ sub to_utf8 {
10831083
# correct, but quoted slashes look too horrible in bookmarks
10841084
sub esc_param {
10851085
my $str = shift;
1086-
$str =~ s/([^A-Za-z0-9\-_.~()\/:@])/sprintf("%%%02X", ord($1))/eg;
1087-
$str =~ s/\+/%2B/g;
1086+
$str =~ s/([^A-Za-z0-9\-_.~()\/:@ ]+)/CGI::escape($1)/eg;
10881087
$str =~ s/ /\+/g;
10891088
return $str;
10901089
}

0 commit comments

Comments
 (0)