Skip to content

Commit 54dbc1f

Browse files
committed
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
2 parents 0591c0a + e8c3531 commit 54dbc1f

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
@@ -6144,7 +6144,16 @@ sub git_blob_plain {
61446144
# want to be sure not to break that by serving the image as an
61456145
# attachment (though Firefox 3 doesn't seem to care).
61466146
my $sandbox = $prevent_xss &&
6147-
$type !~ m!^(?:text/plain|image/(?:gif|png|jpeg))(?:[ ;]|$)!;
6147+
$type !~ m!^(?:text/[a-z]+|image/(?:gif|png|jpeg))(?:[ ;]|$)!;
6148+
6149+
# serve text/* as text/plain
6150+
if ($prevent_xss &&
6151+
($type =~ m!^text/[a-z]+\b(.*)$! ||
6152+
($type =~ m!^[a-z]+/[a-z]\+xml\b(.*)$! && -T $fd))) {
6153+
my $rest = $1;
6154+
$rest = defined $rest ? $rest : '';
6155+
$type = "text/plain$rest";
6156+
}
61486157

61496158
print $cgi->header(
61506159
-type => $type,

0 commit comments

Comments
 (0)