On Sep 9, 2008, at 1:38 PM, Ruediger Pluem wrote:

IMHO the following patch should fix the mod_mbox error by correctly
encoding these chars:

Index: module-2.0/mod_mbox_cte.c
===================================================================
--- module-2.0/mod_mbox_cte.c   (Revision 693585)
+++ module-2.0/mod_mbox_cte.c   (Arbeitskopie)
@@ -91,6 +91,9 @@
        else if (s[i] == '&') {
            j += 4;
        }
+        else if (((unsigned char) s[i]) < 32) {
+            j += 5;
+        }
    }

    /* If there is nothing to escape, just copy the body to the new
@@ -118,6 +121,10 @@
                memcpy(&x[j], "&amp;", 5);
                j += 4;
            }
+            else if (((unsigned char) s[i]) < 32) {
+                apr_snprintf(&x[j], 6, "&#%02i;", s[i]);
+                j += 4;
+            }
            else {
                x[j] = s[i];
            }

Um, this won't make the XML problems go away, because some of those "control chars" < 32 are simply illegal in an XML document, see http://www.w3.org/TR/REC-xml/#NT-Char - this code could produce, for example, &#05; which is just not allowed.

I don't know what the constraints are, but it does seem odd to put "characters" like ASCII ENQ or SO, which have no shared semantics by anything, in something you might send over the Internet. -Tim

Reply via email to