You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rj...@apache.org on 2014/01/09 21:24:35 UTC
svn commit: r1556939 - in /httpd/mod_mbox/trunk/module-2.0: mod_mbox.c
mod_mbox.h mod_mbox_out.c mod_mbox_sitemap.c
Author: rjung
Date: Thu Jan 9 20:24:34 2014
New Revision: 1556939
URL: http://svn.apache.org/r1556939
Log:
Encode ampersand as & when contained verbatim
in message IDs.
Modified:
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
httpd/mod_mbox/trunk/module-2.0/mod_mbox_sitemap.c
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=1556939&r1=1556938&r2=1556939&view=diff
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox.c Thu Jan 9 20:24:34 2014
@@ -205,6 +205,35 @@ char *mbox_cntrl_escape(apr_pool_t *p, c
return x;
}
+/* Escape chars in msg ids which are have special meaning in URIs */
+char *mbox_msg_id_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 (s[i] == '&')
+ /* Length of "&" minus 1 (original character "&") */
+ j += 4;
+
+ if (j == 0)
+ return s;
+
+ x = apr_palloc(p, i + j + 1);
+ for (i = 0, j = 0; s[i] != '\0'; i++, j++) {
+ if (s[i] == '&') {
+ strncpy(&x[j], "&", 5);
+ j += 4;
+ }
+ else
+ x[j] = s[i];
+ }
+
+ x[j] = '\0';
+ return x;
+}
+
static mbox_req_cfg_t *get_req_conf(request_rec *r)
{
mbox_req_cfg_t *conf = ap_get_module_config(r->request_config, &mbox_module);
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=1556939&r1=1556938&r2=1556939&view=diff
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox.h (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox.h Thu Jan 9 20:24:34 2014
@@ -145,6 +145,7 @@ void mbox_mime_display_xml_structure(req
/* Utility functions */
char *mbox_wrap_text(char *str);
char *mbox_cntrl_escape(apr_pool_t *p, char *s);
+char *mbox_msg_id_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);
@@ -157,8 +158,8 @@ const char *get_base_name(request_rec *r
#define ESCAPE_AND_CONV_HDR(pool, s) \
(s ? mbox_cntrl_escape(pool, ap_escape_html(pool, mbox_cte_decode_header(pool, s))) : "")
-#define URI_ESCAPE_OR_BLANK(pool, s) \
-(s ? ap_escape_uri(pool, s) : "")
+#define MSG_ID_ESCAPE_OR_BLANK(pool, s) \
+(s ? ap_escape_uri(pool, mbox_msg_id_escape(pool, s)) : "")
/* Backend functions */
apr_array_header_t *mbox_fetch_boxes_list(request_rec *r,
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=1556939&r1=1556938&r2=1556939&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 Thu Jan 9 20:24:34 2014
@@ -55,9 +55,9 @@ static void display_atom_entry(request_r
ap_rprintf(r, "<link rel=\"alternate\" href=\"%s%s/%s\"/>\n",
ap_construct_url(r->pool, r->uri, r),
- mboxfile, URI_ESCAPE_OR_BLANK(pool, m->msgID));
+ mboxfile, MSG_ID_ESCAPE_OR_BLANK(pool, m->msgID));
- uid = URI_ESCAPE_OR_BLANK(pool, m->msgID);
+ uid = MSG_ID_ESCAPE_OR_BLANK(pool, m->msgID);
c = uid;
while (*c != '\0') {
@@ -452,7 +452,7 @@ static void display_static_msglist_entry
if (linked) {
ap_rprintf(r, "<a href=\"%s\">",
- URI_ESCAPE_OR_BLANK(r->pool, m->msgID));
+ MSG_ID_ESCAPE_OR_BLANK(r->pool, m->msgID));
}
ap_rprintf(r, "%s", ESCAPE_AND_CONV_HDR(r->pool, m->subject));
@@ -1061,7 +1061,7 @@ static void mbox_static_message_nav(requ
if (context[0]) {
ap_rprintf(r, "<a href=\"%s/%s\" "
"title=\"Previous by date\">«</a>",
- baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[0]));
+ baseURI, MSG_ID_ESCAPE_OR_BLANK(r->pool, context[0]));
}
else {
ap_rputs("«", r);
@@ -1073,7 +1073,7 @@ static void mbox_static_message_nav(requ
if (context[1]) {
ap_rprintf(r, "<a href=\"%s/%s\" "
"title=\"Next by date\">»</a>",
- baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[1]));
+ baseURI, MSG_ID_ESCAPE_OR_BLANK(r->pool, context[1]));
}
else {
ap_rputs("»", r);
@@ -1085,7 +1085,7 @@ static void mbox_static_message_nav(requ
if (context[2]) {
ap_rprintf(r, "<a href=\"%s/%s\" "
"title=\"Previous by thread\">«</a>",
- baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[2]));
+ baseURI, MSG_ID_ESCAPE_OR_BLANK(r->pool, context[2]));
}
else {
ap_rputs("«", r);
@@ -1098,7 +1098,7 @@ static void mbox_static_message_nav(requ
if (context[3]) {
ap_rprintf(r, "<a href=\"%s/%s\" "
"title=\"Next by thread\">»</a>",
- baseURI, URI_ESCAPE_OR_BLANK(r->pool, context[3]));
+ baseURI, MSG_ID_ESCAPE_OR_BLANK(r->pool, context[3]));
}
else {
ap_rputs("»", r);
@@ -1207,7 +1207,7 @@ int mbox_static_message(request_rec *r,
ap_rputs(" <tr class=\"mime\">\n"
" <td class=\"left\">Mime</td>\n"
" <td class=\"right\">\n<ul>\n", r);
- escaped_msgID = URI_ESCAPE_OR_BLANK(r->pool, m->msgID);
+ escaped_msgID = MSG_ID_ESCAPE_OR_BLANK(r->pool, m->msgID);
mbox_mime_display_static_structure(r, m->mime_msg,
apr_psprintf(r->pool, "%s/raw/%s/",
baseURI, escaped_msgID));
@@ -1264,7 +1264,7 @@ apr_status_t mbox_xml_message(request_re
" <subject><![CDATA[%s]]></subject>\n"
" <date><![CDATA[%s]]></date>\n"
" <contents><![CDATA[",
- URI_ESCAPE_OR_BLANK(r->pool, m->msgID),
+ MSG_ID_ESCAPE_OR_BLANK(r->pool, m->msgID),
from, subj,
ESCAPE_OR_BLANK(r->pool, m->rfc822_date));
Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_sitemap.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_sitemap.c?rev=1556939&r1=1556938&r2=1556939&view=diff
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox_sitemap.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_sitemap.c Thu Jan 9 20:24:34 2014
@@ -80,7 +80,7 @@ static void mbox2sitemap(request_rec *r,
ap_rprintf(r, "<loc><![CDATA[%s%s/%s]]></loc>\n",
ap_construct_url(tpool, r->uri, r),
- mboxfile, URI_ESCAPE_OR_BLANK(tpool, m->msgID));
+ mboxfile, MSG_ID_ESCAPE_OR_BLANK(tpool, m->msgID));
apr_time_exp_gmt(&extime, m->date);
apr_strftime(dstr, &dlen, sizeof(dstr), "%G-%m-%d", &extime);