]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.perl
gitweb: Serve */*+xml 'blob_plain' as text/plain with $prevent_xss
[Gitweb] / gitweb.perl
index 8c8c293301f4a9f2ee6a4da049880e256d5dead157c17239a6de10eb11997f5b..9199e564e3ad056bb712d29a76cfeba3c36f11a0294ad31a8e12f97e3d0b9581 100755 (executable)
@@ -6359,7 +6359,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,
This page took 1.014713 seconds and 4 git commands to generate.