Ticket #543 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

mod_alias silently ignores aliases with capitals in them

Reported by: samuel _dot_ kvarnbrink _at_ minervaskolan _dot_ se Owned by: jan
Priority: normal Milestone:
Component: mod_alias Version: 1.4.10
Severity: normal Keywords:
Cc: Blocked By:
Need User Feedback: Blocking:

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",
  # ...
)

Attachments

Change History

Changed 3 years ago by moo

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);

Changed 3 years ago by moo

  • status changed from new to closed
  • version changed from 1.4.9 to 1.4.10
  • resolution set to fixed

fixed in [1007]

Changed 3 years ago by marc

  • status changed from closed to reopened
  • resolution fixed deleted

There is a typo in this patch:

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

Thanks.

Changed 2 years ago by moo

  • status changed from reopened to closed
  • resolution set to fixed

thanks, it's in [1010]

Add/Change #543 (mod_alias silently ignores aliases with capitals in them)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.