1
0
Fork 0

misc fix: strip non-essential headers from message part of mm7 packet

This commit is contained in:
bagyenda 2007-08-30 16:35:45 +00:00
parent 4ebf96552e
commit 4208985069
5 changed files with 55 additions and 12 deletions

View File

@ -1012,7 +1012,6 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
{
int i, n, mtype = mms_messagetype(msg);
MSoapMsg_t *m = NULL;
List *headers;
Octstr *xfrom = (from != NULL) ? octstr_format("+ %S", from) : NULL, *s;
Octstr *xuaprof_val = (uaprof) ? octstr_format("%S,%ld", uaprof, uaprof_tstamp) : NULL;
@ -1022,7 +1021,9 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
m = mm7_soap_create(isclientside ? MM7_TAG_SubmitReq : MM7_TAG_DeliverReq,
transid);
m->msg = mms_tomime(msg,1);
strip_non_essential_headers(m->msg);
for (i = 0, n = xto ? gwlist_len(xto) : 0; i < n; i++) { /* Add recipients. */
Octstr *xx = octstr_format("+ %S", gwlist_get(xto, i));
http_header_add(m->envelope, "To",
@ -1102,7 +1103,7 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
octstr_destroy(s);
}
#if 0 /* handled above. */
/* Should we bother to strip message part of headers??? */
headers = mime_entity_headers(m->msg);
http_header_remove_all(headers, "Subject");
@ -1115,6 +1116,7 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
http_header_remove_all(headers, "Bcc");
mime_replace_headers(m->msg, headers);
http_destroy_headers(headers);
#endif
break;
case MMS_MSGTYPE_READ_ORIG_IND:
case MMS_MSGTYPE_DELIVERY_IND:

View File

@ -1650,3 +1650,40 @@ int has_node_children(xmlNodePtr node)
return 1;
return 0;
}
/* strip all but content-type, content-id, content-transfer-disposition, content-location */
void strip_non_essential_headers(MIMEEntity *mime)
{
Octstr *v;
List *h, *h2;
if (!mime) return;
h = mime_entity_headers(mime);
h2 = http_create_empty_headers();
if ((v = http_header_value(h, octstr_imm("Content-Type"))) != NULL) {
http_header_add(h2, "Content-Type", octstr_get_cstr(v));
octstr_destroy(v);
}
if ((v = http_header_value(h, octstr_imm("Content-ID"))) != NULL) {
http_header_add(h2, "Content-ID", octstr_get_cstr(v));
octstr_destroy(v);
}
if ((v = http_header_value(h, octstr_imm("Content-Location"))) != NULL) {
http_header_add(h2, "Content-Location", octstr_get_cstr(v));
octstr_destroy(v);
}
if ((v = http_header_value(h, octstr_imm("Content-Transfer-Encoding"))) != NULL) {
http_header_add(h2, "Content-Transfer-Encoding", octstr_get_cstr(v));
octstr_destroy(v);
}
mime_replace_headers(mime,h2);
http_destroy_headers(h);
http_destroy_headers(h2);
}

View File

@ -194,6 +194,10 @@ char *make_file_ext(Octstr *url, Octstr *ctype, char fext[5]);
/* return true if node has a child... */
int has_node_children(xmlNodePtr node);
/* strip non-essential headers from top-level */
void strip_non_essential_headers(MIMEEntity *mime);
#define MAXQTRIES 100
#define BACKOFF_FACTOR 5*60 /* In seconds */
#define QUEUERUN_INTERVAL 1*60 /* 1 minutes. */

View File

@ -791,12 +791,10 @@ static int add_msg_part(MIMEEntity *res, xmlNodePtr node, Octstr *base_url,
}
done:
if (curl)
octstr_destroy(curl);
if (ctype)
octstr_destroy(ctype);
if (body)
octstr_destroy(body);
octstr_destroy(curl);
octstr_destroy(ctype);
octstr_destroy(body);
xmlFree(src);
return 0;
}

View File

@ -472,11 +472,13 @@ Octstr *mms_find_sender_msisdn(Octstr *send_url,
List *l = octstr_split(send_url, octstr_imm("/"));
Octstr *xip = http_header_value(request_hdrs,
requestip_header);
int len = gwlist_len(l);
if (xip == NULL)
xip = ip ? octstr_duplicate(ip) : NULL;
if (detokenizerfuncs && ((l && gwlist_len(l) > 1) || xip))
phonenum = detokenizerfuncs->mms_detokenize((l && gwlist_len(l) > 1) ?
gwlist_get(l, gwlist_len(l) - 1) :
if (detokenizerfuncs && (len > 1 || xip))
phonenum = detokenizerfuncs->mms_detokenize(len > 1 ?
gwlist_get(l, len - 1) :
send_url,
xip);