Skip to content

Commit 5329c99

Browse files
committed
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
2 parents 4a5a800 + e8c3531 commit 5329c99

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

gitweb/gitweb.perl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6129,7 +6129,16 @@ sub git_blob_plain {
61296129
# want to be sure not to break that by serving the image as an
61306130
# attachment (though Firefox 3 doesn't seem to care).
61316131
my $sandbox = $prevent_xss &&
6132-
$type !~ m!^(?:text/plain|image/(?:gif|png|jpeg))(?:[ ;]|$)!;
6132+
$type !~ m!^(?:text/[a-z]+|image/(?:gif|png|jpeg))(?:[ ;]|$)!;
6133+
6134+
# serve text/* as text/plain
6135+
if ($prevent_xss &&
6136+
($type =~ m!^text/[a-z]+\b(.*)$! ||
6137+
($type =~ m!^[a-z]+/[a-z]\+xml\b(.*)$! && -T $fd))) {
6138+
my $rest = $1;
6139+
$rest = defined $rest ? $rest : '';
6140+
$type = "text/plain$rest";
6141+
}
61336142

61346143
print $cgi->header(
61356144
-type => $type,

0 commit comments

Comments
 (0)