]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitweb: Fix displaying unchopped argument in chop_and_escape_str
authorJakub Narebski <jnareb@gmail.com>
Sat, 16 Feb 2008 22:07:46 +0000 (23:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 Feb 2008 03:29:16 +0000 (19:29 -0800)
Do not use esc_html to escape [title] _attribute_ of a HTML element,
and quote unprintable characters.  Replace unprintable characters by
'?' and use CGI method to generate HTML element and do the escaping.

This caused bug noticed by Martin Koegler,
  Message-ID: <20080216130037.GA14571@auto.tuwien.ac.at>
that for bad commit encoding in author name, the title attribute (here
to show full, not shortened name) had embedded HTML code in it, result
of quoting unprintable characters the gitweb/HTML way. This of course
broke the HTML, causing page being not displayed in XML validating web
browsers.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl

index 5e88637b5e0e67143692bac336a57ab6cc1c0c38..47e3a413466dde701475b1974c669b7e7d0cd63d 100755 (executable)
@@ -866,8 +866,8 @@ sub chop_and_escape_str {
        if ($chopped eq $str) {
                return esc_html($chopped);
        } else {
-               return qq{<span title="} . esc_html($str) . qq{">} .
-                       esc_html($chopped) . qq{</span>};
+               $str =~ s/([[:cntrl:]])/?/g;
+               return $cgi->span({-title=>$str}, esc_html($chopped));
        }
 }