Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 32173 invoked from network); 30 May 2010 03:15:31 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 May 2010 03:15:31 -0000 Received: (qmail 14842 invoked by uid 500); 30 May 2010 03:15:31 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 14632 invoked by uid 500); 30 May 2010 03:15:29 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 14625 invoked by uid 99); 30 May 2010 03:15:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 May 2010 03:15:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 May 2010 03:15:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EA3E523888E4; Sun, 30 May 2010 03:15:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r949463 - in /httpd/mod_mbox/trunk: CHANGES module-2.0/mod_mbox.c module-2.0/mod_mbox.h module-2.0/mod_mbox_out.c Date: Sun, 30 May 2010 03:15:04 -0000 To: cvs@httpd.apache.org From: jerenkrantz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100530031504.EA3E523888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jerenkrantz Date: Sun May 30 03:15:04 2010 New Revision: 949463 URL: http://svn.apache.org/viewvc?rev=949463&view=rev Log: Fix up non-printable character support with Firefox and Google Chrome over AJAX interfaces. For a test case, try lists with rpluem as a member - April 2010 of dev@httpd is a good example: http://mail-archives.apache.org/mod_mbox/httpd-dev/201004.mbox/browser * CHANGES: Note this. * module-2.0/mod_mbox.c (apr_lib.h): Include. (mbox_ascii_escape): Add helper to just HTML-ify non-printable chars based on ap_escape_html2 implementation. * module-2,0/mod_mbox.h (mbox_ascii_escape): Declare. (ESCAPE_OR_BLANK): If available, use ap_escape_html2 or use our internal escape helper on pre-2.3 builds. (URI_ESCAPE_OR_BLANK): Relocate declaration. * module-2.0/mod_mbox_out.c (display_xml_msglist_entry): Re-order from escaping to always escape last. (mbox_xml_message): HTML-escape unprintable chars in body and re-order from. Modified: httpd/mod_mbox/trunk/CHANGES httpd/mod_mbox/trunk/module-2.0/mod_mbox.c httpd/mod_mbox/trunk/module-2.0/mod_mbox.h httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c Modified: httpd/mod_mbox/trunk/CHANGES URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/CHANGES?rev=949463&r1=949462&r2=949463&view=diff ============================================================================== --- httpd/mod_mbox/trunk/CHANGES (original) +++ httpd/mod_mbox/trunk/CHANGES Sun May 30 03:15:04 2010 @@ -1,5 +1,8 @@ Changes for mod_mbox 0.2 + *) Fix up non-printable character support with Firefox and Google Chrome + over AJAX interfaces. [Justin Erenkrantz] + *) Google's Summer of Code 2005 work release : major front-end module rewrite. [Maxime Petazzoni] Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox.c?rev=949463&r1=949462&r2=949463&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod_mbox.c (original) +++ httpd/mod_mbox/trunk/module-2.0/mod_mbox.c Sun May 30 03:15:04 2010 @@ -38,6 +38,8 @@ #include "mod_mbox.h" +#include "apr_lib.h" + /* Register module hooks. */ static void mbox_register_hooks(apr_pool_t *p) @@ -165,6 +167,33 @@ char *mbox_wrap_text(char *str) return str; } +char *mbox_ascii_escape(apr_pool_t *p, const 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])) + j += 5; + + if (j == 0) + return apr_pstrmemdup(p, s, i); + + x = apr_palloc(p, i + j + 1); + for (i = 0, j = 0; s[i] != '\0'; i++, j++) + if (!apr_isascii(s[i])) { + char *esc = apr_psprintf(p, "&#%3.3d;", (unsigned char)s[i]); + memcpy(&x[j], esc, 6); + j += 5; + } + else + x[j] = s[i]; + + x[j] = '\0'; + return x; +} + /* Returns the archives base path */ char *get_base_path(request_rec *r) { Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox.h URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox.h?rev=949463&r1=949462&r2=949463&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod_mbox.h (original) +++ httpd/mod_mbox/trunk/module-2.0/mod_mbox.h Sun May 30 03:15:04 2010 @@ -91,12 +91,6 @@ extern module mbox_module; extern char *mbox_months[12][2]; -#define ESCAPE_OR_BLANK(pool, s) \ -(s ? ap_escape_html(pool, s) : "") - -#define URI_ESCAPE_OR_BLANK(pool, s) \ -(s ? ap_escape_uri(pool, s) : "") - /* Handlers */ int mbox_atom_handler(request_rec *r, mbox_cache_info *mli); int mbox_sitemap_handler(request_rec *r, mbox_cache_info *mli); @@ -147,9 +141,21 @@ 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 *get_base_path(request_rec *r); char *get_base_uri(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 + +#define URI_ESCAPE_OR_BLANK(pool, s) \ +(s ? ap_escape_uri(pool, s) : "") + /* Backend functions */ apr_array_header_t *mbox_fetch_boxes_list(request_rec *r, mbox_cache_info *mli, Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c?rev=949463&r1=949462&r2=949463&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c (original) +++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c Sun May 30 03:15:04 2010 @@ -481,8 +481,7 @@ static void display_xml_msglist_entry(re conf = ap_get_module_config(r->per_dir_config, &mbox_module); - from = ESCAPE_OR_BLANK(r->pool, m->str_from); - from = mbox_cte_decode_header(r->pool, from); + from = mbox_cte_decode_header(r->pool, m->str_from); if (conf->antispam) { from = email_antispam(from); } @@ -490,7 +489,8 @@ static void display_xml_msglist_entry(re ap_rprintf(r, " \n", linked, depth, ESCAPE_OR_BLANK(r->pool, m->msgID)); - ap_rprintf(r, " \n", from); + ap_rprintf(r, " \n", + ESCAPE_OR_BLANK(r->pool, from)); ap_rprintf(r, " \n", ESCAPE_OR_BLANK(r->pool, m->str_date)); @@ -1278,11 +1278,11 @@ apr_status_t mbox_xml_message(request_re ap_rputs("\n", r); - from = ESCAPE_OR_BLANK(r->pool, m->from); - from = mbox_cte_decode_header(r->pool, from); + from = mbox_cte_decode_header(r->pool, m->from); if (conf->antispam) { from = email_antispam(from); } + from = ESCAPE_OR_BLANK(r->pool, from); ap_rprintf(r, "\n" " \n" @@ -1295,7 +1295,7 @@ apr_status_t mbox_xml_message(request_re ESCAPE_OR_BLANK(r->pool, m->rfc822_date)); ap_rprintf(r, "%s", - mbox_wrap_text(mbox_mime_get_body(r->pool, m->mime_msg))); + mbox_ascii_escape(r->pool, mbox_wrap_text(mbox_mime_get_body(r->pool, m->mime_msg)))); ap_rputs("]]>\n", r); ap_rputs(" \n", r); mbox_mime_display_xml_structure(r, m->mime_msg,