summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-10-13 19:51:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-10-14 08:14:45 (GMT)
commit452e2256d2d7cb5494ca10fcbbb6bdf29570f2c0 (patch)
tree52608e3345969b95819461fb281fe382bf00f815
parent6ff9ae9f97101c30897332f608f35ad232b1faf2 (diff)
downloadgit-452e2256d2d7cb5494ca10fcbbb6bdf29570f2c0.zip
git-452e2256d2d7cb5494ca10fcbbb6bdf29570f2c0.tar.gz
git-452e2256d2d7cb5494ca10fcbbb6bdf29570f2c0.tar.bz2
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>
-rwxr-xr-xgitweb/gitweb.perl3
1 files changed, 1 insertions, 2 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 24b2193..4b21ad2 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1083,8 +1083,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;
}