From: Dirk-Willem van Gulik Date: Tue, 14 Mar 2000 13:32:08 +0000 (+0000) Subject: Nasty backwards compatibility breaking 'fix' to get rid of X-Git-Tag: APACHE_2_0_ALPHA_2~88 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b779325522acabcfe64a3e8011c9a42ade358830;p=apache Nasty backwards compatibility breaking 'fix' to get rid of ErrorDocument 201 "Some string without a closing quote case which is just pure ugly. I am _NOT_ going to be offended if anyone rolls back this patch OR if anyone suggests to have an ErrorDocument2 which the proper syntax/semantics. But I thought lets take my chance whilst everyone is still recovering from the apachecon. Dw. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84764 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/conf/httpd-std.conf b/docs/conf/httpd-std.conf index ecc0f4b4f8..39004fc5bf 100644 --- a/docs/conf/httpd-std.conf +++ b/docs/conf/httpd-std.conf @@ -723,20 +723,25 @@ AddType application/x-tar .tgz # these come in three flavors # # 1) plain text -#ErrorDocument 500 "The server made a boo boo. -# n.b. the (") marks it as text, it does not get output +#ErrorDocument 500 "The server made a boo boo." # # 2) local redirects #ErrorDocument 404 /missing.html # to redirect to local URL /missing.html -#ErrorDocument 404 /cgi-bin/missing_handler.pl +#ErrorDocument 404 "/cgi-bin/missing_handlder.pl" +# i.e. any string which starts with a '/' and has +# no spaces. # N.B.: You can redirect to a script or a document using server-side-includes. # # 3) external redirects #ErrorDocument 402 http://some.other_server.com/subscription_info.html +# i.e. any string whichis a valid URL. # N.B.: Many of the environment variables associated with the original # request will *not* be available to such a script. - +# +# 4) borderline case +#ErrorDocument 402 "http://some.other_server.com/info.html is the place to look" +# treated as case '1' as it has spaces and thus is not a valid URL # # The following directives modify normal HTTP response behavior. # The first directive disables keepalive for Netscape 2.x and browsers that diff --git a/docs/conf/httpd-win.conf b/docs/conf/httpd-win.conf index 3eca7ef3de..e5f9c1a8ef 100644 --- a/docs/conf/httpd-win.conf +++ b/docs/conf/httpd-win.conf @@ -655,20 +655,25 @@ AddType application/x-tar .tgz # these come in three flavors # # 1) plain text -#ErrorDocument 500 "The server made a boo boo. -# n.b. the (") marks it as text, it does not get output +#ErrorDocument 500 "The server made a boo boo." # # 2) local redirects #ErrorDocument 404 /missing.html # to redirect to local URL /missing.html -#ErrorDocument 404 /cgi-bin/missing_handler.pl +#ErrorDocument 404 "/cgi-bin/missing_handlder.pl" +# i.e. any string which starts with a '/' and has +# no spaces. # N.B.: You can redirect to a script or a document using server-side-includes. # # 3) external redirects #ErrorDocument 402 http://some.other_server.com/subscription_info.html +# i.e. any string whichis a valid URL. # N.B.: Many of the environment variables associated with the original # request will *not* be available to such a script. - +# +# 4) borderline case +#ErrorDocument 402 "http://some.other_server.com/info.html is the place to look" +# treated as case '1' as it has spaces and thus is not a valid URL # # The following directives disable keepalives and HTTP header flushes. # The first directive disables it for Netscape 2.x and browsers which diff --git a/modules/http/http_core.c b/modules/http/http_core.c index 0bb8447e2b..e1e66f2518 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -1080,9 +1080,10 @@ API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string) } static const char *set_error_document(cmd_parms *cmd, core_dir_config *conf, - char *line) + char *errno_str, char *msg) { int error_number, index_number, idx500; + enum { MSG, LOCAL_PATH, REMOTE_PATH } what = MSG; char *w; const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); @@ -1093,10 +1094,7 @@ static const char *set_error_document(cmd_parms *cmd, core_dir_config *conf, /* 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); - + error_number = atoi(errno_str); idx500 = ap_index_of_response(HTTP_INTERNAL_SERVER_ERROR); if (error_number == HTTP_INTERNAL_SERVER_ERROR) { @@ -1104,13 +1102,22 @@ static const char *set_error_document(cmd_parms *cmd, core_dir_config *conf, } else if ((index_number = ap_index_of_response(error_number)) == idx500) { return ap_pstrcat(cmd->pool, "Unsupported HTTP response code ", - w, NULL); - } - + errno_str, NULL); + } + + /* Heuristic to determine second argument. */ + if (strchr(msg,' ')) + what = MSG; + else if (msg[0] == '/') + what = LOCAL_PATH; + else if (ap_is_url(msg)) + what = REMOTE_PATH; + else + what = MSG; + /* The entry should be ignored if it is a full URL for a 401 error */ - if (error_number == 401 && - line[0] != '/' && line[0] != '"') { /* Ignore it... */ + if (error_number == 401 && what == REMOTE_PATH) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, cmd->server, "cannot use a full URL in a 401 ErrorDocument " "directive --- ignoring!"); @@ -1121,7 +1128,13 @@ static const char *set_error_document(cmd_parms *cmd, core_dir_config *conf, ap_pcalloc(cmd->pool, sizeof(*conf->response_code_strings) * RESPONSE_CODES); } - conf->response_code_strings[index_number] = ap_pstrdup(cmd->pool, line); + /* hack. Prefix a " if it is a msg; as that is what + * http_protocol.c relies on to distinguish between + * a msg and a (local) path. + */ + conf->response_code_strings[index_number] = (what == MSG) ? + ap_pstrcat(cmd->pool, "\"",msg,NULL) : + ap_pstrdup(cmd->pool, msg); } return NULL; @@ -2335,7 +2348,7 @@ static const command_rec core_cmds[] = { "Name(s) of per-directory config files (default: .htaccess)" }, { "DocumentRoot", set_document_root, NULL, RSRC_CONF, TAKE1, "Root directory of the document tree" }, -{ "ErrorDocument", set_error_document, NULL, OR_FILEINFO, RAW_ARGS, +{ "ErrorDocument", set_error_document, NULL, OR_FILEINFO, TAKE2, "Change responses for HTTP errors" }, { "AllowOverride", set_override, NULL, ACCESS_CONF, RAW_ARGS, "Controls what groups of directives can be configured by per-directory "