summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-08-16 18:41:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-08-16 18:41:26 (GMT)
commit5329c99795e187b36a527baa883efe5c3dc2f98c (patch)
tree411f04d30b0a6a4895c7a2a6e1f05dfbb8cfba43
parent4a5a8008fde47a4c999657515b396d53153bec3d (diff)
parente8c35317172aab9da7afe555da603021a3ae89e5 (diff)
downloadgit-5329c99795e187b36a527baa883efe5c3dc2f98c.zip
git-5329c99795e187b36a527baa883efe5c3dc2f98c.tar.gz
git-5329c99795e187b36a527baa883efe5c3dc2f98c.tar.bz2
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-xgitweb/gitweb.perl11
1 files changed, 10 insertions, 1 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 81dacf2..50a835a 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,