misc fix: strip non-essential headers from message part of mm7 packet
This commit is contained in:
parent
4ebf96552e
commit
4208985069
|
@ -1012,7 +1012,6 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
|
||||||
{
|
{
|
||||||
int i, n, mtype = mms_messagetype(msg);
|
int i, n, mtype = mms_messagetype(msg);
|
||||||
MSoapMsg_t *m = NULL;
|
MSoapMsg_t *m = NULL;
|
||||||
List *headers;
|
|
||||||
Octstr *xfrom = (from != NULL) ? octstr_format("+ %S", from) : NULL, *s;
|
Octstr *xfrom = (from != NULL) ? octstr_format("+ %S", from) : NULL, *s;
|
||||||
Octstr *xuaprof_val = (uaprof) ? octstr_format("%S,%ld", uaprof, uaprof_tstamp) : NULL;
|
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,
|
m = mm7_soap_create(isclientside ? MM7_TAG_SubmitReq : MM7_TAG_DeliverReq,
|
||||||
transid);
|
transid);
|
||||||
m->msg = mms_tomime(msg,1);
|
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. */
|
for (i = 0, n = xto ? gwlist_len(xto) : 0; i < n; i++) { /* Add recipients. */
|
||||||
Octstr *xx = octstr_format("+ %S", gwlist_get(xto, i));
|
Octstr *xx = octstr_format("+ %S", gwlist_get(xto, i));
|
||||||
http_header_add(m->envelope, "To",
|
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);
|
octstr_destroy(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* handled above. */
|
||||||
/* Should we bother to strip message part of headers??? */
|
/* Should we bother to strip message part of headers??? */
|
||||||
headers = mime_entity_headers(m->msg);
|
headers = mime_entity_headers(m->msg);
|
||||||
http_header_remove_all(headers, "Subject");
|
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");
|
http_header_remove_all(headers, "Bcc");
|
||||||
mime_replace_headers(m->msg, headers);
|
mime_replace_headers(m->msg, headers);
|
||||||
http_destroy_headers(headers);
|
http_destroy_headers(headers);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case MMS_MSGTYPE_READ_ORIG_IND:
|
case MMS_MSGTYPE_READ_ORIG_IND:
|
||||||
case MMS_MSGTYPE_DELIVERY_IND:
|
case MMS_MSGTYPE_DELIVERY_IND:
|
||||||
|
|
|
@ -1650,3 +1650,40 @@ int has_node_children(xmlNodePtr node)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -194,6 +194,10 @@ char *make_file_ext(Octstr *url, Octstr *ctype, char fext[5]);
|
||||||
|
|
||||||
/* return true if node has a child... */
|
/* return true if node has a child... */
|
||||||
int has_node_children(xmlNodePtr node);
|
int has_node_children(xmlNodePtr node);
|
||||||
|
|
||||||
|
/* strip non-essential headers from top-level */
|
||||||
|
void strip_non_essential_headers(MIMEEntity *mime);
|
||||||
|
|
||||||
#define MAXQTRIES 100
|
#define MAXQTRIES 100
|
||||||
#define BACKOFF_FACTOR 5*60 /* In seconds */
|
#define BACKOFF_FACTOR 5*60 /* In seconds */
|
||||||
#define QUEUERUN_INTERVAL 1*60 /* 1 minutes. */
|
#define QUEUERUN_INTERVAL 1*60 /* 1 minutes. */
|
||||||
|
|
|
@ -791,12 +791,10 @@ static int add_msg_part(MIMEEntity *res, xmlNodePtr node, Octstr *base_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (curl)
|
|
||||||
octstr_destroy(curl);
|
octstr_destroy(curl);
|
||||||
if (ctype)
|
octstr_destroy(ctype);
|
||||||
octstr_destroy(ctype);
|
octstr_destroy(body);
|
||||||
if (body)
|
|
||||||
octstr_destroy(body);
|
|
||||||
xmlFree(src);
|
xmlFree(src);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,11 +472,13 @@ Octstr *mms_find_sender_msisdn(Octstr *send_url,
|
||||||
List *l = octstr_split(send_url, octstr_imm("/"));
|
List *l = octstr_split(send_url, octstr_imm("/"));
|
||||||
Octstr *xip = http_header_value(request_hdrs,
|
Octstr *xip = http_header_value(request_hdrs,
|
||||||
requestip_header);
|
requestip_header);
|
||||||
|
int len = gwlist_len(l);
|
||||||
|
|
||||||
if (xip == NULL)
|
if (xip == NULL)
|
||||||
xip = ip ? octstr_duplicate(ip) : NULL;
|
xip = ip ? octstr_duplicate(ip) : NULL;
|
||||||
if (detokenizerfuncs && ((l && gwlist_len(l) > 1) || xip))
|
if (detokenizerfuncs && (len > 1 || xip))
|
||||||
phonenum = detokenizerfuncs->mms_detokenize((l && gwlist_len(l) > 1) ?
|
phonenum = detokenizerfuncs->mms_detokenize(len > 1 ?
|
||||||
gwlist_get(l, gwlist_len(l) - 1) :
|
gwlist_get(l, len - 1) :
|
||||||
send_url,
|
send_url,
|
||||||
xip);
|
xip);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue