From: Eric Covener Date: Mon, 13 Jan 2014 01:42:12 +0000 (+0000) Subject: restore http://svn.apache.org/viewvc?view=revision&revision=233369 X-Git-Tag: 2.5.0-alpha~4644 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae4277941e6dbac6288b2ee0cb91ad6d5af3fd4b;p=apache restore http://svn.apache.org/viewvc?view=revision&revision=233369 under a configurable option: don't run mod_dir if r->handler is already set. PR53794 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1557640 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 79359ea4bb..bd99d4295c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + + *) mod_dir: Add DirectoryCheckHandler to allow a 2.2-like behavior, skipping + execution when a handler is already set. PR53929. [Eric Covener] + *) mod_rewrite: Protect against looping with the [N] flag by enforcing a default limit of 10000 iterations, and allowing each rule to change its limit. [Eric Covener] diff --git a/docs/manual/mod/mod_dir.xml b/docs/manual/mod/mod_dir.xml index 081f679c91..fe30af422a 100644 --- a/docs/manual/mod/mod_dir.xml +++ b/docs/manual/mod/mod_dir.xml @@ -274,5 +274,31 @@ a directory + +DirectoryCheckHandler +Toggle how this module responds when another handler is configured +DirectoryCheckHandler On|Off +DirectorySlash Off +server configvirtual host +directory.htaccess +Indexes +Available in 2.4.8 and later. Releases prior to 2.4 implicitly +act as if "DirectorySlash Off" was specified. + +

The DirectoryCheckHandler directive determines + whether mod_dir should check for directory indexes or + add trailing slashes when some other handler has been configured for + the current URL. Handlers can be set by directives such as + SetHandler or by other modules, + such as mod_rewrite during per-directory substitutions. +

+ +

In releases prior to 2.4, this module did not take any action if any + other handler was configured for a URL. This allows directory indexes to + be served even when a SetHandler directive is + specified for an entire directory, but it can also result in some conflicts + with modules such as mod_rewrite.

+
+
diff --git a/modules/mappers/mod_dir.c b/modules/mappers/mod_dir.c index 0b40a9807f..a309a98390 100644 --- a/modules/mappers/mod_dir.c +++ b/modules/mappers/mod_dir.c @@ -44,6 +44,7 @@ typedef enum { typedef struct dir_config_struct { apr_array_header_t *index_names; moddir_cfg do_slash; + moddir_cfg checkhandler; int redirect_index; const char *dflt; } dir_config_rec; @@ -86,6 +87,13 @@ static const char *configure_slash(cmd_parms *cmd, void *d_, int arg) d->do_slash = arg ? MODDIR_ON : MODDIR_OFF; return NULL; } +static const char *configure_checkhandler(cmd_parms *cmd, void *d_, int arg) +{ + dir_config_rec *d = d_; + + d->checkhandler = arg ? MODDIR_ON : MODDIR_OFF; + return NULL; +} static const char *configure_redirect(cmd_parms *cmd, void *d_, const char *arg1) { dir_config_rec *d = d_; @@ -123,6 +131,8 @@ static const command_rec dir_cmds[] = "a list of file names"), AP_INIT_FLAG("DirectorySlash", configure_slash, NULL, DIR_CMD_PERMS, "On or Off"), + AP_INIT_FLAG("DirectoryCheckHandler", configure_checkhandler, NULL, DIR_CMD_PERMS, + "On or Off"), AP_INIT_TAKE1("DirectoryIndexRedirect", configure_redirect, NULL, DIR_CMD_PERMS, "On, Off, or a 3xx status code."), @@ -135,6 +145,7 @@ static void *create_dir_config(apr_pool_t *p, char *dummy) new->index_names = NULL; new->do_slash = MODDIR_UNSET; + new->checkhandler = MODDIR_UNSET; new->redirect_index = REDIRECT_UNSET; return (void *) new; } @@ -148,6 +159,8 @@ static void *merge_dir_configs(apr_pool_t *p, void *basev, void *addv) new->index_names = add->index_names ? add->index_names : base->index_names; new->do_slash = (add->do_slash == MODDIR_UNSET) ? base->do_slash : add->do_slash; + new->checkhandler = + (add->checkhandler == MODDIR_UNSET) ? base->checkhandler : add->checkhandler; new->redirect_index= (add->redirect_index == REDIRECT_UNSET) ? base->redirect_index : add->redirect_index; new->dflt = add->dflt ? add->dflt : base->dflt; @@ -260,6 +273,10 @@ static int fixup_dir(request_rec *r) return HTTP_MOVED_PERMANENTLY; } + if (d->checkhandler == MODDIR_ON && strcmp(r->handler, DIR_MAGIC_TYPE)) { + return DECLINED; + } + if (d->index_names) { names_ptr = (char **)d->index_names->elts; num_names = d->index_names->nelts;