git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: use correct mime type even if filename has multiple dots.

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 17, 2006, 08:23 UTC
Message-ID
<eej0l8$36t$1@sea.gmane.org>
In-Reply-To
<20060917075157.GY17042@admingilde.org>
Martin Waitz wrote:
Show 17 quoted lines
> hoi :)
> 
> On Sat, Sep 16, 2006 at 11:44:52PM +0200, Jakub Narebski wrote:
>> Martin Waitz wrote:
>> 
>> > Match the last part of the filename agains the extention from the
>> > mime database instead of insisting that it starts at the first dot.
>> [...]
>> > -     $filename =~ /\.(.*?)$/;
>> > -     return $mimemap{$1};
>> 
>> Actually, that is non-greedy match, so the above code insist that 
>> extension starts at the _last_ dot.
> 
> hmm, but it didn't work for me.
> I had filenames like "man/program.8.html" which got served as
> "text/html" with the old code.

And why it shouldn't? From the extension it is HTML page, I would guess manpage converted to HTML (pretty-printed manpage). And it should be served with text/html mimetype.

> Besides, the new code would cope with extentions that contain a
> dot itself.
But is unnecessary complicated, and I guess performance suffers a bit.
> Looking at /etc/mime.types, it only contains pcf.Z but perhaps
So the *.pcf.Z file wouldn't get correct mimetype. No big.
> it should also contain tar.gz or similiar.
You can't properly serve tar.gz as something other than with
application/x-gzip mimetype. If you want to serve it as/with 
application/x-tar mimetype, you would need to add 
        Content-Encoding: x-gzip
in addition to
        Content-Type: application/x-tar
And your code doesn't do that.
The _last_ extension defines the type.

Besides, with the exception of files which can be displayed in browser, i.e. HTML files and images it doesn't matter what the mimetype is, if only binary files get binary mimetype (e.g. generic application/octet-stream).

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Previous: Martin WaitzNext: Martin Waitz
Message 4 of 10 in “gitweb: use correct mime type even if filename has multiple dots.”
  1. gitweb: use correct mime type even if filename has multiple dots.Martin Waitz, Sep 16, 2006
  2. Jakub NarebskiSep 16, 2006
  3. Martin WaitzSep 17, 2006
  4. Jakub NarebskiSep 17, 2006
  5. Martin WaitzSep 19, 2006
  6. gitweb: Fix mimetype_guess_file for files with multiple extensionsJakub Narebski, Sep 19, 2006
  7. Junio C HamanoSep 17, 2006
  8. Jakub NarebskiSep 17, 2006
  9. Junio C HamanoSep 17, 2006
  10. Martin WaitzSep 19, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.