Skip to content

Commit bee6ea1

Browse files
jnarebgitster
authored andcommitted
gitweb: Fix usability of $prevent_xss
With XSS prevention on (enabled using $prevent_xss), blobs ('blob_plain') of all types except a few known safe ones are served with "Content-Disposition: attachment". However the check was too strict; it didn't take into account optional parameter attributes, media-type = type "/" subtype *( ";" parameter ) as described in RFC 2616 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7 This fixes that, and it for example treats following as safe MIME media type: text/plain; charset=utf-8 Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e1100e commit bee6ea1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gitweb/gitweb.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4752,7 +4752,7 @@ sub git_blob_plain {
47524752
# want to be sure not to break that by serving the image as an
47534753
# attachment (though Firefox 3 doesn't seem to care).
47544754
my $sandbox = $prevent_xss &&
4755-
$type !~ m!^(?:text/plain|image/(?:gif|png|jpeg))$!;
4755+
$type !~ m!^(?:text/plain|image/(?:gif|png|jpeg))(?:[ ;]|$)!;
47564756

47574757
print $cgi->header(
47584758
-type => $type,

0 commit comments

Comments
 (0)