From: Jim Jagielski Date: Tue, 20 Nov 2007 14:08:46 +0000 (+0000) Subject: Merge r595646, r595648 from trunk: X-Git-Tag: 2.2.7~213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1a94e75b032fd033daf62419fe10f66bb096aba;p=thirdparty%2Fapache%2Fhttpd.git Merge r595646, r595648 from trunk: Finish up http://svn.apache.org/viewvc?view=rev&revision=102066 http://svn.apache.org/viewvc?view=rev&revision=102205 from almost 4 years ago by removing abandoned logic from the fixup hook. no logic changes just minor style fixes Submitted by: trawick Reviewed by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@596681 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/STATUS b/STATUS index 3211663902c..d2fe258d509 100644 --- a/STATUS +++ b/STATUS @@ -109,14 +109,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: niq says: done jim: +1 - * mod_charset_lite cleanups to remove long-abandoned logic and fix - some minor style problems - trunk: - http://svn.apache.org/viewvc?rev=595646&view=rev - http://svn.apache.org/viewvc?rev=595648&view=rev - 2.2.x: trunk patch applies - +1: trawick, rpluem, jim - * mod_ssl: Don't use the pconf pool for allocating memory pointed by a local static variable. PR 43865. trunk: diff --git a/modules/filters/mod_charset_lite.c b/modules/filters/mod_charset_lite.c index 1489e4316ce..ed8ecbe5ca2 100644 --- a/modules/filters/mod_charset_lite.c +++ b/modules/filters/mod_charset_lite.c @@ -189,9 +189,9 @@ static const char *add_charset_options(cmd_parms *cmd, void *in_dc, return NULL; } -/* find_code_page() is a fixup hook that decides if translation should be - * enabled; if so, it sets up request data for use by the filter registration - * hook so that it knows what to do +/* find_code_page() is a fixup hook that checks if the module is + * configured and the input or output potentially need to be translated. + * If so, context is initialized for the filters. */ static int find_code_page(request_rec *r) { @@ -200,7 +200,6 @@ static int find_code_page(request_rec *r) charset_req_t *reqinfo; charset_filter_ctx_t *input_ctx, *output_ctx; apr_status_t rv; - const char *mime_type; if (dc->debug >= DBGLVL_FLOW) { ap_log_rerror(APLOG_MARK,APLOG_DEBUG, 0, r, @@ -229,7 +228,10 @@ static int find_code_page(request_rec *r) } /* catch proxy requests */ - if (r->proxyreq) return DECLINED; + if (r->proxyreq) { + return DECLINED; + } + /* mod_rewrite indicators */ if (r->filename && (!strncmp(r->filename, "redirect:", 9) @@ -238,54 +240,10 @@ static int find_code_page(request_rec *r) || !strncmp(r->filename, "forbidden:", 10))) { return DECLINED; } - /* no translation when server and network charsets are set to the same value */ - if (!strcasecmp(dc->charset_source, dc->charset_default)) return DECLINED; - - mime_type = r->content_type ? r->content_type : ap_default_type(r); - - /* If mime type isn't text or message, bail out. - */ - -/* XXX When we handle translation of the request body, watch out here as - * 1.3 allowed additional mime types: multipart and - * application/x-www-form-urlencoded - */ - - if (strncasecmp(mime_type, "text/", 5) && -#if APR_CHARSET_EBCDIC || AP_WANT_DIR_TRANSLATION - /* On an EBCDIC machine, be willing to translate mod_autoindex- - * generated output. Otherwise, it doesn't look too cool. - * - * XXX This isn't a perfect fix because this doesn't trigger us - * to convert from the charset of the source code to ASCII. The - * general solution seems to be to allow a generator to set an - * indicator in the r specifying that the body is coded in the - * implementation character set (i.e., the charset of the source - * code). This would get several different types of documents - * translated properly: mod_autoindex output, mod_status output, - * mod_info output, hard-coded error documents, etc. - */ - strcmp(mime_type, DIR_MAGIC_TYPE) && -#endif - strncasecmp(mime_type, "message/", 8)) { - if (dc->debug >= DBGLVL_GORY) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, - "mime type is %s; no translation selected", - mime_type); - } - /* We must not bail out here (i.e., the MIME test must be in the filter - * itself, not in the fixup, because only then is the final MIME type known. - * Examples for late changes to the MIME type include CGI handling (MIME - * type is set in the Content-Type header produced by the CGI script), or - * PHP (until PHP runs, the MIME type is set to application/x-httpd-php) - */ - } - if (dc->debug >= DBGLVL_GORY) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, - "charset_source: %s charset_default: %s", - dc && dc->charset_source ? dc->charset_source : "(none)", - dc && dc->charset_default ? dc->charset_default : "(none)"); + /* no translation when server and network charsets are set to the same value */ + if (!strcasecmp(dc->charset_source, dc->charset_default)) { + return DECLINED; } /* Get storage for the request data and the output filter context. @@ -302,14 +260,6 @@ static int find_code_page(request_rec *r) reqinfo->output_ctx = output_ctx; - /* We must not open the xlation table here yet, because the final MIME - * type is not known until we are actually called in the output filter. - * With POST or PUT request, the case is different, because their MIME - * type is set in the request headers, and their data are prerequisites - * for actually calling, e.g., the CGI handler later on. - */ - output_ctx->xlate = NULL; - switch (r->method_number) { case M_PUT: case M_POST: @@ -832,18 +782,11 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb) } } - /* Opening the output translation (this used to be done in the fixup hook, - * but that was too early: a subsequent type modification, e.g., by a - * CGI script, would go unnoticed. Now we do it in the filter itself.) + /* Check the mime type to see if translation should be performed. */ - if (!ctx->noop && ctx->xlate == NULL) - { + if (!ctx->noop && ctx->xlate == NULL) { const char *mime_type = f->r->content_type ? f->r->content_type : ap_default_type(f->r); - /* XXX When we handle translation of the request body, watch out here as - * 1.3 allowed additional mime types: multipart and - * application/x-www-form-urlencoded - */ if (strncasecmp(mime_type, "text/", 5) == 0 || #if APR_CHARSET_EBCDIC /* On an EBCDIC machine, be willing to translate mod_autoindex- @@ -858,12 +801,12 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb) * translated properly: mod_autoindex output, mod_status output, * mod_info output, hard-coded error documents, etc. */ - strcmp(mime_type, DIR_MAGIC_TYPE) == 0 || + strcmp(mime_type, DIR_MAGIC_TYPE) == 0 || #endif - strncasecmp(mime_type, "message/", 8) == 0) { + strncasecmp(mime_type, "message/", 8) == 0) { rv = apr_xlate_open(&ctx->xlate, - dc->charset_default, dc->charset_source, f->r->pool); + dc->charset_default, dc->charset_source, f->r->pool); if (rv != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, "can't open translation %s->%s", @@ -877,20 +820,21 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb) } } else { - ctx->noop = 1; - if (dc->debug >= DBGLVL_GORY) - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, - "mime type is %s; no translation selected", - mime_type); + ctx->noop = 1; + if (dc->debug >= DBGLVL_GORY) { + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, + "mime type is %s; no translation selected", + mime_type); } + } } if (dc->debug >= DBGLVL_GORY) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, - "xlate_out_filter() - " - "charset_source: %s charset_default: %s", - dc && dc->charset_source ? dc->charset_source : "(none)", - dc && dc->charset_default ? dc->charset_default : "(none)"); + "xlate_out_filter() - " + "charset_source: %s charset_default: %s", + dc && dc->charset_source ? dc->charset_source : "(none)", + dc && dc->charset_default ? dc->charset_default : "(none)"); } if (!ctx->ran) { /* filter never ran before */