httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1226512 - in /httpd/mod_mbox/branches/convert-charsets/module-2.0: mod_mbox.c mod_mbox.h mod_mbox_out.c
Date Mon, 02 Jan 2012 18:50:44 GMT
Author: sf
Date: Mon Jan  2 18:50:43 2012
New Revision: 1226512

URL: http://svn.apache.org/viewvc?rev=1226512&view=rev
Log:
Only escape control chars; other non-ascii chars are supposed to be UTF8
now.

If we escape them byte for byte, clients will interpret every multi-byte
character as several characters.

Modified:
    httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c
    httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.h
    httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_out.c

Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c?rev=1226512&r1=1226511&r2=1226512&view=diff
==============================================================================
--- httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c (original)
+++ httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.c Mon Jan  2 18:50:43 2012
@@ -177,22 +177,23 @@ char *mbox_wrap_text(char *str)
     return str;
 }
 
-char *mbox_ascii_escape(apr_pool_t *p, const char *s)
+/* Escape control chars */
+char *mbox_cntrl_escape(apr_pool_t *p, char *s)
 {
     int i, j;
     char *x;
 
     /* first, count the number of extra characters */
     for (i = 0, j = 0; s[i] != '\0'; i++)
-        if (!apr_isascii(s[i]))
+        if (apr_iscntrl(s[i]))
             j += 5;
 
     if (j == 0)
-        return apr_pstrmemdup(p, s, i);
+        return s;
 
     x = apr_palloc(p, i + j + 1);
     for (i = 0, j = 0; s[i] != '\0'; i++, j++)
-        if (!apr_isascii(s[i])) {
+        if (apr_iscntrl(s[i])) {
             char *esc = apr_psprintf(p, "&#%3.3d;", (unsigned char)s[i]);
             memcpy(&x[j], esc, 6);
             j += 5;

Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.h
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.h?rev=1226512&r1=1226511&r2=1226512&view=diff
==============================================================================
--- httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.h (original)
+++ httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox.h Mon Jan  2 18:50:43 2012
@@ -144,18 +144,13 @@ void mbox_mime_display_xml_structure(req
 
 /* Utility functions */
 char *mbox_wrap_text(char *str);
-char *mbox_ascii_escape(apr_pool_t *p, const char *s);
+char *mbox_cntrl_escape(apr_pool_t *p, char *s);
 const char *get_base_path(request_rec *r);
 const char *get_base_uri(request_rec *r);
 const char *get_base_name(request_rec *r);
 
-#if AP_MODULE_MAGIC_AT_LEAST(20081231,0)
 #define ESCAPE_OR_BLANK(pool, s) \
-(s ? ap_escape_html2(pool, s, 1) : "")
-#else
-#define ESCAPE_OR_BLANK(pool, s) \
-(s ? mbox_ascii_escape(pool, ap_escape_html(pool, s)) : "")
-#endif
+(s ? mbox_cntrl_escape(pool, ap_escape_html(pool, s)) : "")
 
 #define URI_ESCAPE_OR_BLANK(pool, s) \
 (s ? ap_escape_uri(pool, s) : "")

Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_out.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_out.c?rev=1226512&r1=1226511&r2=1226512&view=diff
==============================================================================
--- httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_out.c (original)
+++ httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_out.c Mon Jan  2 18:50:43
2012
@@ -85,7 +85,7 @@ static void display_atom_entry(request_r
                                              m->cte, m->boundary);
 
     ap_rprintf(r, "%s",
-               mbox_ascii_escape(pool, mbox_wrap_text(mbox_mime_get_body(pool, m->mime_msg))));
+               mbox_cntrl_escape(pool, mbox_wrap_text(mbox_mime_get_body(pool, m->mime_msg))));
 
     ap_rputs("\n</pre>\n</div>\n</content>\n", r);
     ap_rputs("</entry>\n", r);
@@ -1272,7 +1272,7 @@ apr_status_t mbox_xml_message(request_re
                ESCAPE_OR_BLANK(r->pool, m->rfc822_date));
 
     ap_rprintf(r, "%s",
-               mbox_ascii_escape(r->pool, mbox_wrap_text(mbox_mime_get_body(r->pool,
m->mime_msg))));
+               mbox_cntrl_escape(r->pool, mbox_wrap_text(mbox_mime_get_body(r->pool,
m->mime_msg))));
     ap_rputs("]]></contents>\n", r);
     ap_rputs(" <mime>\n", r);
     mbox_mime_display_xml_structure(r, m->mime_msg,



Mime
View raw message