akosut 97/09/09 11:39:19
Modified: src/main http_core.c Log: Canonicalize Windows pathnames in <Directory> and <Files> sections, so they will match the filenames you expect them to match. Also do case-insentitive matching for <DirectoryMatch> and <FilesMatch>, for the same reason. Reviewed by: Ben Laurie Revision Changes Path 1.119 +25 -6 apachen/src/main/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apachen/src/main/http_core.c,v retrieving revision 1.118 retrieving revision 1.119 diff -u -u -r1.118 -r1.119 --- http_core.c 1997/09/02 16:12:08 1.118 +++ http_core.c 1997/09/09 18:39:17 1.119 @@ -753,6 +753,16 @@ return NULL; } +/* We use this in <DirectoryMatch> and <FilesMatch>, to ensure that + * people don't get bitten by wrong-cased regex matches + */ + +#ifdef WIN32 +#define USE_ICASE REG_ICASE +#else +#define USE_ICASE 0 +#endif + static const char end_dir_magic[] = "</Directory> outside of any <Directory> section"; const char *end_dirsection (cmd_parms *cmd, void *dummy) { @@ -782,11 +792,15 @@ cmd->override = OR_ALL|ACCESS_CONF; if (cmd->info) { /* <DirectoryMatch> */ - r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); } else if (!strcmp(cmd->path, "~")) { cmd->path = getword_conf (cmd->pool, &arg); - r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); + } + else { + /* Ensure that the pathname is canonical */ + cmd->path = os_canonical_filename(cmd->pool, cmd->path); } errmsg = srm_command_loop (cmd, new_dir_conf); @@ -881,16 +895,21 @@ if (cmd->info) { /* <FilesMatch> */ if (old_path && cmd->path[0] != '/' && cmd->path[0] != '^') cmd->path = pstrcat(cmd->pool, "^", old_path, cmd->path, NULL); - r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); } else if (!strcmp(cmd->path, "~")) { cmd->path = getword_conf (cmd->pool, &arg); if (old_path && cmd->path[0] != '/' && cmd->path[0] != '^') cmd->path = pstrcat(cmd->pool, "^", old_path, cmd->path, NULL); - r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED); + r = pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); + } + else { + if (old_path && cmd->path[0] != '/') + cmd->path = pstrcat(cmd->pool, old_path, cmd->path, NULL); + + /* Ensure that the pathname is canonical */ + cmd->path = os_canonical_filename(cmd->pool, cmd->path); } - else if (old_path && cmd->path[0] != '/') - cmd->path = pstrcat(cmd->pool, old_path, cmd->path, NULL); errmsg = srm_command_loop (cmd, new_file_conf); if (errmsg != end_file_magic) return errmsg;