@matheusbsbs / matheus-bagliano / commits / 25ffbb27a2
Fork 0

gitweb: protect blob and diff output lines from controls.

This revealed that the output from blame and tag was not chomped properly and was relying on HTML output not noticing that extra whitespace that resulted from the newline, which was also fixed. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 8, 2006 at 15:11 UTC 25ffbb27a20278e9884e8f036b39806bb11ec1a8
1 file changed +6 -5
gitweb/gitweb.perl
+6 -5
@@ -576,11 +576,10 @@ sub esc_html ($;%) {
576
577 $str = to_utf8($str);
578 $str = escapeHTML($str);
579 - $str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)
580 - $str =~ s/\033/^[/g; # "escape" ESCAPE (\e) character (e.g. commit 20a3847d8a5032ce41f90dcc68abfb36e6fee9b1)
579 if ($opts{'-nbsp'}) {
580 $str =~ s/ /&nbsp;/g;
581 }
582 + $str =~ s|([[:cntrl:]])|(($1 ne "\t") ? quot_cec($1) : $1)|eg;
583 return $str;
584 }
585
@@ -1879,17 +1878,17 @@ sub git_print_page_path {
1878 $fullname .= ($fullname ? '/' : '') . $dir;
1879 print $cgi->a({-href => href(action=>"tree", file_name=>$fullname,
1880 hash_base=>$hb),
1882 - -title => $fullname}, esc_path($dir));
1881 + -title => esc_html($fullname)}, esc_path($dir));
1882 print " / ";
1883 }
1884 if (defined $type && $type eq 'blob') {
1885 print $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name,
1886 hash_base=>$hb),
1888 - -title => $name}, esc_path($basename));
1887 + -title => esc_html($name)}, esc_path($basename));
1888 } elsif (defined $type && $type eq 'tree') {
1889 print $cgi->a({-href => href(action=>"tree", file_name=>$file_name,
1890 hash_base=>$hb),
1892 - -title => $name}, esc_path($basename));
1891 + -title => esc_html($name)}, esc_path($basename));
1892 print " / ";
1893 } else {
1894 print esc_path($basename);
@@ -2851,6 +2850,7 @@ sub git_tag {
2850 print "<div class=\"page_body\">";
2851 my $comment = $tag{'comment'};
2852 foreach my $line (@$comment) {
2853 + chomp($line);
2854 print esc_html($line) . "<br/>\n";
2855 }
2856 print "</div>\n";
@@ -2920,6 +2920,7 @@ HTML
2920 }
2921 }
2922 my $data = $_;
2923 + chomp($data);
2924 my $rev = substr($full_rev, 0, 8);
2925 my $author = $meta->{'author'};
2926 my %date = parse_date($meta->{'author-time'},