]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Fix displaying unchopped argument in chop_and_escape_str
authorJakub Narebski <redacted>
Sat, 16 Feb 2008 22:07:46 +0000 (23:07 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:07:12 +0000 (00:07 -0400)
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: <redacted>
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 5a5fb61c03422c8aabdb3ee836e2893aabbf856482e846854503a98cd39393eb..dd5283cf4b7cabbd22ae86a877670696675093fa9a792253e79a0d0b1d1ed28b 100755 (executable)
@@ -867,8 +867,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));
        }
 }
 
This page took 0.286031 seconds and 4 git commands to generate.