diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-07-19 09:45:41 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-07-19 09:45:41 -0700 |
commit | 54dbc1f9e6451b6673835259ce8aa450489fc420 (patch) | |
tree | 362dcd69a764b9e4120188e1d420632e7bb9abce /gitweb | |
parent | 0591c0a5be7d58dfe2c69c8a81b2cebbb0337320 (diff) | |
parent | e8c35317172aab9da7afe555da603021a3ae89e5 (diff) | |
download | git-54dbc1f9e6451b6673835259ce8aa450489fc420.tar.gz |
Merge branch 'jn/mime-type-with-params'
* 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
Diffstat (limited to 'gitweb')
-rwxr-xr-x | gitweb/gitweb.perl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index a62b510ba7..f3e567c8d7 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -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, |