Project

General

Profile

Actions

Bug #543

closed

mod_alias silently ignores aliases with capitals in them

Added by Anonymous over 16 years ago. Updated almost 16 years ago.

Status:
Fixed
Priority:
Normal
Category:
mod_alias
Target version:
-
ASK QUESTIONS IN Forums:

Description

I've stumbled upon some interesting behavior in mod_alias: When an alias is created and the path contains capital letters, it is silently ignored. All requests to the specified path result in a 404, and it doesn't make any difference whether or not the visitor supplies the path exactly as it is written in the config, all in lowercase or all in uppercase. However, the aliasing is case-insensitive as long as the alias path is written all in lowercase in the config file. A few examples:

with `server.alias("/MinervaMovies/" => "/Library/WebServer/Documents/MinervaMovies"`:
`http://server_address/MinervaMovies/index.html` => 404
`http://server_address/minervamovies/index.html` => 404

with `server.alias("/minervamovies/" => "/Library/WebServer/Documents/MinervaMovies"`:
`http://server_address/MinervaMovies/index.html` => 200, all ok
`http://server_address/minervamovies/index.html` => 200

My lighttpd.conf looks like this. I've removed all 404 handler and fcgi server parts to make sure they aren't causing the problem. I'm running 1.4.9 under Mac OS X 10.4.4.


server.port = 3000

server.modules           = ( "mod_rewrite", "mod_fastcgi", "mod_alias", "mod_accesslog" )
alias.url = ("/MinervaMovies/" => "/Library/WebServer/Documents/MinervaMovies/")
server.document-root     = "/opt/cms/current/public/" 

server.errorlog          = "/opt/cms/shared/log/lighttpd.error.log" 
accesslog.filename       = "/opt/cms/shared/log/lighttpd.access.log" 

url.rewrite              = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )

mimetype.assign = (
  ".html"       =>  "text/html",
  # ...
)

-- samuel dot kvarnbrink at minervaskolan dot se

Actions #1

Updated by moo over 16 years ago

have u turned on server.force-lowercase-filenames? if so can u pls try the following patch?


Index: mod_alias.c
===================================================================
--- mod_alias.c (revision 1006)
+++ mod_alias.c (working copy)
@@ -166,7 +166,9 @@
        if (alias_len > uri_len) continue;
        if (ds->key->used == 0) continue;

-       if (0 == strncmp(uri_ptr, ds->key->ptr, alias_len)) {
+       if (0 == (con->conf.force_lowercase_filenames ?
+                   strncastcmp(uri_ptr, ds->key->ptr, alias_len) :
+                   strncmp(uri_ptr, ds->key->ptr, alias_len))) {
            /* matched */

            buffer_copy_string_buffer(con->physical.basedir, ds->value);
Actions #2

Updated by moo over 16 years ago

  • Status changed from New to Fixed
  • Resolution set to fixed

fixed in r1007

Actions #3

Updated by marc over 16 years ago

  • Status changed from Fixed to Need Feedback
  • Resolution deleted (fixed)

There is a typo in this patch:

the call to strcastcmp() should be strcasecmp().

Thanks.

Actions #4

Updated by moo over 16 years ago

  • Status changed from Need Feedback to Fixed
  • Resolution set to fixed

thanks, it's in r1010

Actions

Also available in: Atom