]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
applied.
authorJim Jagielski <jim@apache.org>
Tue, 20 Nov 2007 13:58:09 +0000 (13:58 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 20 Nov 2007 13:58:09 +0000 (13:58 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@596672 13f79535-47bb-0310-9956-ffa450edef68

STATUS
modules/filters/mod_charset_lite.c

diff --git a/STATUS b/STATUS
index 13671f54174de9677393404745182db466632717..677d258c5af790c60e83dd34830a560f07e83677 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -109,17 +109,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
      niq says: done
      jim: +1
 
-   * mod_charset_lite: Remove Content-Length when output filter can 
-     invalidate it.  Warn when input filter can invalidate it.
-     trunk:
-        http://svn.apache.org/viewvc?view=rev&revision=380232
-        http://svn.apache.org/viewvc?view=rev&revision=593890
-     2.2.x:
-        Trunk patches work when applied in succession, but a consolidated
-        patch is at 
-        http://people.apache.org/~trawick/sb-charset-consolidated.txt
-     +1: trawick, niq, jim
-
     * mod_autoindex: Generate valid XHTML output by adding the xhtml namespace.
       Trunk version of patch:
          http://svn.apache.org/viewcvs.cgi?rev=593816&view=rev
index 5b7d7c892503f888448e8d631e03283404a5f479..1489e4316ce2a227ebc23488b667adc46906d5a4 100644 (file)
@@ -85,6 +85,7 @@ typedef struct charset_dir_t {
  */
 typedef struct charset_filter_ctx_t {
     apr_xlate_t *xlate;
+    int is_sb;              /* single-byte translation? */
     charset_dir_t *dc;
     ees_t ees;              /* extended error status */
     apr_size_t saved;
@@ -330,6 +331,9 @@ static int find_code_page(request_rec *r)
                           dc->charset_default, dc->charset_source);
             return HTTP_INTERNAL_SERVER_ERROR;
         }
+        if (apr_xlate_sb_get(input_ctx->xlate, &input_ctx->is_sb) != APR_SUCCESS) {
+            input_ctx->is_sb = 0;
+        }
     }
 
     return DECLINED;
@@ -866,6 +870,11 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
                               dc->charset_source, dc->charset_default);
                 ctx->noop = 1;
             }
+            else {
+                if (apr_xlate_sb_get(ctx->xlate, &ctx->is_sb) != APR_SUCCESS) {
+                    ctx->is_sb = 0;
+                }
+            }
         }
         else {
                 ctx->noop = 1;
@@ -887,6 +896,12 @@ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
     if (!ctx->ran) {  /* filter never ran before */
         chk_filter_chain(f);
         ctx->ran = 1;
+        if (!ctx->noop && !ctx->is_sb) {
+            /* We're not converting between two single-byte charsets, so unset
+             * Content-Length since it is unlikely to remain the same.
+             */
+            apr_table_unset(f->r->headers_out, "Content-Length");
+        }
     }
 
     if (ctx->noop) {
@@ -1045,6 +1060,23 @@ static int xlate_in_filter(ap_filter_t *f, apr_bucket_brigade *bb,
     if (!ctx->ran) {  /* filter never ran before */
         chk_filter_chain(f);
         ctx->ran = 1;
+        if (!ctx->noop && !ctx->is_sb
+            && apr_table_get(f->r->headers_in, "Content-Length")) {
+            /* A Content-Length header is present, but it won't be valid after
+             * conversion because we're not converting between two single-byte
+             * charsets.  This will affect most CGI scripts and may affect
+             * some modules.
+             * Content-Length can't be unset here because that would break
+             * being able to read the request body.
+             * Processing of chunked request bodies is not impacted by this
+             * filter since the the length was not declared anyway.
+             */
+            if (dc->debug >= DBGLVL_PMC) {
+                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r,
+                              "Request body length may change, resulting in "
+                              "misprocessing by some modules or scripts");
+            }
+        }
     }
 
     if (ctx->noop) {