X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=etc%2Flighttpd%2Fscripts%2Fcreate-mime.assign.pl;h=858600f07c3389a8d13ef7c5f13f3b86ec45560c;hb=a73e0429667aa897d78217a70cabdbae5ffecd98;hp=fbc4cf0af9207cdb811cfdf49fbd9be8d5f8fe0a;hpb=2dd30a95203a9b6b5d441f54797e01f262bf96c7;p=matthijs%2Fservers%2Fdrsnuggles.git diff --git a/etc/lighttpd/scripts/create-mime.assign.pl b/etc/lighttpd/scripts/create-mime.assign.pl index fbc4cf0..858600f 100755 --- a/etc/lighttpd/scripts/create-mime.assign.pl +++ b/etc/lighttpd/scripts/create-mime.assign.pl @@ -1,18 +1,27 @@ #!/usr/bin/perl -w # This script is based on /usr/share/lighttpd/create-mime-assign.pl. This -# script is changed to include a charset for text types. +# script is changed to include a charset for text types. It is also changed to +# serve some file types as text/plain, since browsers still don't have an +# option to just view text/* in the browser, but need external programs for +# anything but text/plain. use strict; open MIMETYPES, "/etc/mime.types" or exit; print "mimetype.assign = (\n"; my %extensions; +my %translate_types = ( + "text/x-diff" => "text/plain", +); + while() { chomp; s/\#.*//; next if /^\w*$/; if(/^([a-z0-9\/+-.]+)\s+((?:[a-z0-9.+-]+[ ]?)+)$/) { my $mime = $1; my $exts = $2; + # Translate the mime type if needed + $mime = $translate_types{$mime} if exists $translate_types{$mime}; # Append encoding for text formats if ($mime =~ /^text\//) { $mime .= "; charset=utf-8";