summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Narębski <jnareb@gmail.com>2014-05-27 16:22:42 +0200
committerJunio C Hamano <gitster@pobox.com>2014-05-27 15:11:49 -0700
commitd49c08256b41e27879454a1f872bcfb80877acad (patch)
tree0b033ddcdd794dc3a8b3d6dbb58e1ce019234a93
parenteea591373e139fc8aab89a78ccb0b1512a2bf0de (diff)
downloadgit-jn/gitweb-utf8-in-links.tar.gz
gitweb: Harden UTF-8 handling in generated linksjn/gitweb-utf8-in-links
esc_html() ensures that its input is properly UTF-8 encoded and marked as UTF-8 with to_utf8(). Make esc_param() (used for query parameters in generated URLs), esc_path_info() (for escaping path_info components) and esc_url() use it too. This hardens gitweb against errors in UTF-8 handling; because to_utf8() is idempotent it won't change correct output. Reported-by: Michael Wagner <accounts@mwagner.org> Signed-off-by: Jakub Narębski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgitweb/gitweb.perl7
1 files changed, 7 insertions, 0 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 52108b9255..006cd80c3e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1548,8 +1548,11 @@ sub to_utf8 {
sub esc_param {
my $str = shift;
return undef unless defined $str;
+
+ $str = to_utf8($str);
$str =~ s/([^A-Za-z0-9\-_.~()\/:@ ]+)/CGI::escape($1)/eg;
$str =~ s/ /\+/g;
+
return $str;
}
@@ -1558,6 +1561,7 @@ sub esc_path_info {
my $str = shift;
return undef unless defined $str;
+ $str = to_utf8($str);
# path_info doesn't treat '+' as space (specially), but '?' must be escaped
$str =~ s/([^A-Za-z0-9\-_.~();\/;:@&= +]+)/CGI::escape($1)/eg;
@@ -1568,8 +1572,11 @@ sub esc_path_info {
sub esc_url {
my $str = shift;
return undef unless defined $str;
+
+ $str = to_utf8($str);
$str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&= ]+)/CGI::escape($1)/eg;
$str =~ s/ /\+/g;
+
return $str;
}