Downloading a .docx file through a HTML rewriting reverse-proxy suddenly
increased file size by 5 kB. So looking at

  modules/filters/mod_xml2enc :: static apr_status_t
xml2enc_ffunc(ap_filter_t* f, apr_bucket_brigade* bb)

I saw the following

    /* only act if starts-with "text/" or contains "xml" */
    if (strncmp(ctype, "text/", 5) && !strstr(ctype, "xml"))  {
        ap_remove_output_filter(f);
        return ap_pass_brigade(f->next, bb) ;
    }

    (...)

What's this supposed to do with .docx files ? They are (usually) registered
as

  application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx

which I would think not suitable for HTML rewriting. Hence I suggest

diff --git a/modules/filters/mod_xml2enc.c b/modules/filters/mod_xml2enc.c
index 13608ed..0ad35aa 100644
--- a/modules/filters/mod_xml2enc.c
+++ b/modules/filters/mod_xml2enc.c
@@ -336,6 +336,15 @@ static apr_status_t xml2enc_ffunc(ap_filter_t* f,
apr_bucket_brigade* bb)
         return ap_pass_brigade(f->next, bb) ;
     }

+    /* 'docx-patch': do not touch application ctypes, even if they contain
"xml" */
+    if (!strncmp(ctype, "application", 11)) {
+      ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "application ctype
detected, removing filter");
+      ap_remove_output_filter(f);
+      return ap_pass_brigade(f->next, bb);
+    }
+
     if (ctx->bbsave == NULL) {
         ctx->bbsave = apr_brigade_create(f->r->pool,
                                          f->r->connection->bucket_alloc);

This of course goes for all such x-typed document formats, since all of
their corresponding mime types start with "application".

Cheers,
  Thomas

Attachment: docx.patch
Description: Binary data

Reply via email to