@matheusbsbs / matheus-bagliano / commits / 452e2256d2
Fork 0

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 <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Giuseppe Bilotta committed Oct 13, 2009 at 21:51 UTC 452e2256d2d7cb5494ca10fcbbb6bdf29570f2c0
1 file changed +1 -2
gitweb/gitweb.perl
+1 -2
@@ -1083,8 +1083,7 @@ sub to_utf8 {
1083 # correct, but quoted slashes look too horrible in bookmarks
1084 sub esc_param {
1085 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;
1087 $str =~ s/ /\+/g;
1088 return $str;
1089 }