diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-08-16 11:41:26 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-08-16 11:41:26 -0700 |
commit | 5329c99795e187b36a527baa883efe5c3dc2f98c (patch) | |
tree | 411f04d30b0a6a4895c7a2a6e1f05dfbb8cfba43 | |
parent | 4a5a8008fde47a4c999657515b396d53153bec3d (diff) | |
parent | e8c35317172aab9da7afe555da603021a3ae89e5 (diff) | |
download | git-5329c99795e187b36a527baa883efe5c3dc2f98c.tar.gz |
Merge branch 'jn/mime-type-with-params' into maint
* 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
-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 81dacf2b6a..50a835a5bf 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -6129,7 +6129,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, |