On Nov 10, 2007 9:14 AM, Nick Kew <[EMAIL PROTECTED]> wrote:
> On Sat, 10 Nov 2007 14:00:16 -0000
> [EMAIL PROTECTED] wrote:
>
> > +   * 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
> > +     2.2.x:
> > +        Trunk version of patch works
> > +     +1: trawick
> > +
>
> -0.
>
> As you note, that's a non-fix for the input filter.
> Unsetting content-length for input should move to the
> find_code_page function (on a fixup hook).

That would break reading the request body (assuming client used c-l).
ap_http_filter(), which runs after the fixup hook, must see the c-l.
I don't see a way to indicate that the Content-Length may not be
correct.  CGIs could break.

The attached patch describes the situation more accurately and doesn't
raise a concern unless the request actually had a c-l header.

I haven't thought of how to get to the end of the rainbow starting at either

* create a way to indicate to the handler that c-l is unknown without
breaking the reading of the request body
* provide an optional filter to compute c-l (buffering up to some
configured limit)

Thoughts?
Index: modules/filters/mod_charset_lite.c
===================================================================
--- modules/filters/mod_charset_lite.c  (revision 593813)
+++ modules/filters/mod_charset_lite.c  (working copy)
@@ -1060,15 +1060,21 @@
     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 note
-             * that some handlers can't deal with it.
-             * It doesn't help to unset Content-Length in the input header
-             * table since in all likelihood the handler has already seen it.
+        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 are 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, breaking some 
requests");
+                              "Request body length may change, resulting in "
+                              "misprocessing by some modules or scripts");
             }
         }
     }

Reply via email to