From: William A. Rowe Jr Date: Thu, 13 Dec 2001 19:13:23 +0000 (+0000) Subject: As suggested by Josh Slive, add the explicit 'default' to AcceptPathInfo. X-Git-Tag: 2.0.30~209 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97ff8a3f1f8c00ba219885b3b0b9744084eef647;p=apache As suggested by Josh Slive, add the explicit 'default' to AcceptPathInfo. I'll leave docs up to him. The conf becomes a quadstate (undef != default) but other than that, it should make things cleaner for the user. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92459 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/httpd.h b/include/httpd.h index 258cb407b3..aca094ace9 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -593,7 +593,7 @@ struct ap_method_list_t { #endif /* APR_CHARSET_EBCDIC */ /** - * @defgroup values_requet_rec_body Possible values for request_rec.read_body + * @defgroup values_request_rec_body Possible values for request_rec.read_body * @{ * Possible values for request_rec.read_body (set by handling module): */ @@ -606,6 +606,20 @@ struct ap_method_list_t { #define REQUEST_CHUNKED_DECHUNK 2 /** @} */ +/** + * @defgroup values_request_rec_used_path_info Possible values for request_rec.used_path_info + * @{ + * Possible values for request_rec.used_path_info: + */ + +/** Accept request given path_info */ +#define AP_REQ_ACCEPT_PATH_INFO 0 +/** Send 404 error if path_info was given */ +#define AP_REQ_REJECT_PATH_INFO 1 +/** Module's choice for handling path_info */ +#define AP_REQ_DEFAULT_PATH_INFO 2 +/** @} */ + /* * Things which may vary per file-lookup WITHIN a request --- * e.g., state of MIME config. Basically, the name of an object, info @@ -854,9 +868,13 @@ struct request_rec { /** components of uri, dismantled */ apr_uri_t parsed_uri; - /** Flag for the core handler to permit path_info on the current - filename, to be consumed by some filter. Unless this is - toggled, path_info requests are rejected by the core */ + /** Flag for the handler to accept or reject path_info on + * the current request. All modules should respect the + * AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO + * values, while AP_REQ_DEFAULT_PATH_INFO indicates they + * may follow existing conventions. This is set to the + * user's preference upon HOOK_VERY_FIRST of the fixups. + */ int used_path_info; /* Various other config info which may change with .htaccess files diff --git a/server/core.c b/server/core.c index d334b27dd2..3a076243f2 100644 --- a/server/core.c +++ b/server/core.c @@ -131,7 +131,7 @@ static void *create_core_dir_config(apr_pool_t *a, char *dir) conf->override = dir ? OR_UNSET : OR_UNSET|OR_ALL; conf->content_md5 = 2; - conf->accept_path_info = 2; + conf->accept_path_info = AP_REQ_DEFAULT_PATH_INFO; conf->use_canonical_name = USE_CANONICAL_NAME_UNSET; @@ -255,7 +255,7 @@ static void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv) if ((new->content_md5 & 2) == 0) { conf->content_md5 = new->content_md5; } - if ((new->accept_path_info & 2) == 0) { + if (new->accept_path_info != 3) { conf->accept_path_info = new->accept_path_info; } if (new->use_canonical_name != USE_CANONICAL_NAME_UNSET) { @@ -1774,11 +1774,23 @@ static const char *set_content_md5(cmd_parms *cmd, void *d_, int arg) return NULL; } -static const char *set_accept_path_info(cmd_parms *cmd, void *d_, int arg) +static const char *set_accept_path_info(cmd_parms *cmd, void *d_, const char *arg) { core_dir_config *d=d_; - - d->accept_path_info = arg != 0; + + if (strcasecmp(arg, "on") == 0) { + d->accept_path_info = AP_REQ_ACCEPT_PATH_INFO; + } + else if (strcasecmp(arg, "off") == 0) { + d->accept_path_info = AP_REQ_REJECT_PATH_INFO; + } + else if (strcasecmp(arg, "default") == 0) { + d->accept_path_info = AP_REQ_DEFAULT_PATH_INFO; + } + else { + return "AcceptPathInfo must be set to on, off or default"; + } + return NULL; } @@ -2437,8 +2449,8 @@ AP_INIT_TAKE1("GprofDir", set_gprof_dir, NULL, RSRC_CONF, #endif AP_INIT_TAKE1("AddDefaultCharset", set_add_default_charset, NULL, OR_FILEINFO, "The name of the default charset to add to any Content-Type without one or 'Off' to disable"), -AP_INIT_FLAG("AcceptPathInfo", set_accept_path_info, NULL, OR_FILEINFO, - "whether or not files with PATH_INFO will be served by the core handler"), +AP_INIT_TAKE1("AcceptPathInfo", set_accept_path_info, NULL, OR_FILEINFO, + "Set to on or off for PATH_INFO to be accepted by handlers, or default for the per-handler preference"), /* Old resource config file commands */ @@ -2692,8 +2704,10 @@ static int core_override_type(request_rec *r) * if the value is no longer undefined (2), so any module changing * the value prior to the fixup phase OVERRIDES the user's choice. */ - if (r->used_path_info == 2) + if ((r->used_path_info == AP_REQ_DEFAULT_PATH_INFO) + && (conf->accept_path_info != 3)) { r->used_path_info = conf->accept_path_info; + } return OK; }