git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: use correct mime type even if filename has multiple dots.
@ 2006-09-16 21:09 Martin Waitz
  2006-09-16 21:44 ` Jakub Narebski
  0 siblings, 1 reply; 10+ messages in thread
From: Martin Waitz @ 2006-09-16 21:09 UTC (permalink / raw)
  To: git

Match the last part of the filename agains the extention from the
mime database instead of insisting that it starts at the first dot.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 gitweb/gitweb.perl |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ee561c6..7501251 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1106,7 +1106,6 @@ sub mimetype_guess_file {
 	my $mimemap = shift;
 	-r $mimemap or return undef;
 
-	my %mimemap;
 	open(MIME, $mimemap) or return undef;
 	while (<MIME>) {
 		next if m/^#/; # skip comments
@@ -1114,14 +1113,16 @@ sub mimetype_guess_file {
 		if (defined $exts) {
 			my @exts = split(/\s+/, $exts);
 			foreach my $ext (@exts) {
-				$mimemap{$ext} = $mime;
+				if ($filename =~ /\.$ext$/) {
+					close(MIME);
+					return $mime;
+				}
 			}
 		}
 	}
 	close(MIME);
 
-	$filename =~ /\.(.*?)$/;
-	return $mimemap{$1};
+	return undef;
 }
 
 sub mimetype_guess {
-- 
1.4.2.gb8b6b

-- 
Martin Waitz

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-09-19 11:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-16 21:09 [PATCH] gitweb: use correct mime type even if filename has multiple dots Martin Waitz
2006-09-16 21:44 ` Jakub Narebski
2006-09-17  7:51   ` Martin Waitz
2006-09-17  8:23     ` Jakub Narebski
2006-09-19  8:29       ` Martin Waitz
2006-09-19 11:57         ` [PATCH] gitweb: Fix mimetype_guess_file for files with multiple extensions Jakub Narebski
2006-09-17  8:41     ` [PATCH] gitweb: use correct mime type even if filename has multiple dots Junio C Hamano
2006-09-17  8:56       ` Jakub Narebski
2006-09-17  9:07         ` Junio C Hamano
2006-09-19  9:23       ` Martin Waitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).