summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2011-08-16 11:41:26 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2011-08-16 11:41:26 -0700
commit5329c99795e187b36a527baa883efe5c3dc2f98c (patch)
tree411f04d30b0a6a4895c7a2a6e1f05dfbb8cfba43
parentMerge branch 'jc/submodule-sync-no-auto-vivify' into maint (diff)
parentgitweb: Serve */*+xml 'blob_plain' as text/plain with $prevent_xss (diff)
downloadtgif-5329c99795e187b36a527baa883efe5c3dc2f98c.tar.xz
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 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,