Apache UnsetErrorDocument Patch Brian Shire & Facebook Inc. Provides a way to unset ErrorDocument directive. This is useful when you have an automated configuration setup which requires overriding default files. ErrorDocument cannot be "unset" to it's default state. This patch provides a UnsetErrorDocument directive to reset any previous ErrorDocument configurations. To use: Apply the patch with the following commands: cd apache-1.3.x patch -p1 -i ap_UnsetErrorDocument.patch Add the following line to your Apache configuration file(s) to unset an ErrorDocument configuration: UnsetErrorDocument ie: UnsetErrorDocument 404 Provide feedback to diff --git a/src/main/http_core.c b/src/main/http_core.c index c29dc87..8a29ea9 100644 --- a/src/main/http_core.c +++ b/src/main/http_core.c @@ -1326,6 +1326,49 @@ static const char *set_error_document(cmd_parms *cmd, core_dir_config *conf, return NULL; } +/**** BEGIN PATCH: "UnsetErrorDocument", (c)2007 Brian Shire & Facbeook Inc, Licensed under MIT License ***/ +static const char *unset_error_document(cmd_parms *cmd, core_dir_config *conf, + char *line) +{ + int error_number, index_number, idx500; + char *w; + + const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); + if (err != NULL) { + return err; + } + + /* 1st parameter should be a 3 digit number, which we recognize; + * convert it into an array index + */ + + w = ap_getword_conf_nc(cmd->pool, &line); + error_number = atoi(w); + + idx500 = ap_index_of_response(HTTP_INTERNAL_SERVER_ERROR); + + if (error_number == HTTP_INTERNAL_SERVER_ERROR) { + index_number = idx500; + } + else if ((index_number = ap_index_of_response(error_number)) == idx500) { + return ap_pstrcat(cmd->pool, "Unsupported HTTP response code ", + w, NULL); + } + + /* The entry should be ignored if it is a full URL for a 401 error */ + + /* Store it... */ + if (conf->response_code_strings == NULL) { + /* we shouldn't have to do anything, just return. */ + return NULL; + //conf->response_code_strings = ap_pcalloc(cmd->pool, sizeof(*conf->response_code_strings) * RESPONSE_CODES); + } + conf->response_code_strings[index_number] = NULL; + + return NULL; +} +/**** END PATCH: "UnsetErrorDocument" ***/ + /* access.conf commands... * * The *only* thing that can appear in access.conf at top level is a @@ -3546,6 +3589,10 @@ static const command_rec core_cmds[] = { "Root directory of the document tree" }, { "ErrorDocument", set_error_document, NULL, OR_FILEINFO, RAW_ARGS, "Change responses for HTTP errors" }, +/**** BEGIN PATCH: "UnsetErrorDocument", (c)2007 Brian Shire & Facbeook Inc, Licensed under MIT License ***/ +{ "UnsetErrorDocument", unset_error_document, NULL, OR_FILEINFO, RAW_ARGS, + "Reset to default responses for HTTP errors" }, +/*** END PATCH: "UnsetErrorDocument" ***/ { "AllowOverride", set_override, NULL, ACCESS_CONF, RAW_ARGS, "Controls what groups of directives can be configured by per-directory " "config files" },