Skip to content

Commit

Permalink
Merge branch 'jn/mime-type-with-params'
Browse files Browse the repository at this point in the history
* jn/mime-type-with-params:
  gitweb: Serve */*+xml 'blob_plain' as text/plain with $prevent_xss
  gitweb: Serve text/* 'blob_plain' as text/plain with $prevent_xss
  • Loading branch information
Junio C Hamano committed Jul 19, 2011
2 parents 0591c0a + e8c3531 commit 54dbc1f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -6144,7 +6144,16 @@ sub git_blob_plain {
# want to be sure not to break that by serving the image as an
# attachment (though Firefox 3 doesn't seem to care).
my $sandbox = $prevent_xss &&
$type !~ m!^(?:text/plain|image/(?:gif|png|jpeg))(?:[ ;]|$)!;
$type !~ m!^(?:text/[a-z]+|image/(?:gif|png|jpeg))(?:[ ;]|$)!;

# serve text/* as text/plain
if ($prevent_xss &&
($type =~ m!^text/[a-z]+\b(.*)$! ||
($type =~ m!^[a-z]+/[a-z]\+xml\b(.*)$! && -T $fd))) {
my $rest = $1;
$rest = defined $rest ? $rest : '';
$type = "text/plain$rest";
}

print $cgi->header(
-type => $type,
Expand Down

0 comments on commit 54dbc1f

Please sign in to comment.