diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index 626c7b1..bbaaf8a 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -5,7 +5,7 @@ 2007-06-21 P. A. Bagyenda * Better configurability of MM7/SOAP namespace URI and MM7 version. 2007-06-12 P. A. Bagyenda - * Improved DLR reporting over MM4 interface - set receipient as from address + * Improved DLR reporting over MM4 interface - set recipient as from address 2007-05-08 P. A. Bagyenda * Improved MIME to MMS conversion conversion 2007-05-05 P. A. Bagyenda diff --git a/mbuni/configure.ac b/mbuni/configure.ac index d031e5c..4499a52 100644 --- a/mbuni/configure.ac +++ b/mbuni/configure.ac @@ -1,6 +1,6 @@ dnl Mbuni - Open Source MMS Gateway dnl -dnl Copyright (C) 2003 - 2006, Digital Solutions Ltd. - http://www.dsmagic.com +dnl Copyright (C) 2003 - 2007, Digital Solutions Ltd. - http://www.dsmagic.com dnl dnl Paul Bagyenda dnl @@ -279,7 +279,7 @@ cat<mmsbox_mt_filter.h for details. Also see mm7-mt-filter-params config variable in the VAS specific config section. diff --git a/mbuni/mmlib/mms_util.c b/mbuni/mmlib/mms_util.c index a015719..ccc7122 100644 --- a/mbuni/mmlib/mms_util.c +++ b/mbuni/mmlib/mms_util.c @@ -1253,7 +1253,7 @@ Octstr *filename2content_type(char *fname) return octstr_imm("application/octet-stream"); } -char *content_type2file_ext(Octstr *ctype) +static char *content_type2file_ext(Octstr *ctype) { int i; for (i = 0; exts[i].file_ext; i++) @@ -1263,6 +1263,26 @@ char *content_type2file_ext(Octstr *ctype) return "dat"; } +char *make_file_ext(Octstr *url, Octstr *ctype, char fext[5]) +{ + fext[0] = 0; + if (url) { + HTTPURLParse *h = parse_url(url); + char *s, *p; + if (!h) + goto done; + + s = h->path ? octstr_get_cstr(h->path) : ""; + + if ((p = strrchr(s, '.')) != NULL) + strncpy(fext, p+1, 4); /* max length of 4. */ + + http_urlparse_destroy(h); + if (fext[0]) return fext; + } + done: + return content_type2file_ext(ctype); +} static int fetch_url_with_auth(HTTPCaller *c, int method, Octstr *url, List *request_headers, Octstr *body, Octstr *auth_hdr, List **reply_headers, Octstr **reply_body); diff --git a/mbuni/mmlib/mms_util.h b/mbuni/mmlib/mms_util.h index f4aa773..f21ae23 100644 --- a/mbuni/mmlib/mms_util.h +++ b/mbuni/mmlib/mms_util.h @@ -189,8 +189,8 @@ int mms_is_token(Octstr *token); /* try to guess content type from file name extension. */ Octstr *filename2content_type(char *fname); -/* try to give a good extension name based on the content type. */ -char *content_type2file_ext(Octstr *ctype); +/* try to give a good extension name based on the url or content type. */ +char *make_file_ext(Octstr *url, Octstr *ctype, char fext[5]); #define MAXQTRIES 100 #define BACKOFF_FACTOR 5*60 /* In seconds */ diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c index 36fde30..cbdcd66 100644 --- a/mbuni/mmsbox/mmsbox.c +++ b/mbuni/mmsbox/mmsbox.c @@ -734,7 +734,7 @@ static int add_msg_part(MIMEEntity *res, xmlNodePtr node, Octstr *base_url, } if (ctype && body) { /* If we got it, put it in. */ - char *fext = content_type2file_ext(ctype); + char _fext[5] = {0}, *fext = make_file_ext(curl, ctype, _fext); Octstr *attr = octstr_format("cid:%06d.%s", ++cntr,fext); char *p = octstr_get_cstr(attr) + 4; Octstr *cid_header_val = octstr_format("<%s>", p); @@ -953,9 +953,9 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, } else { /* all others, make the message as-is and hope for the best! */ List *xh = http_create_empty_headers(); - if (mt_multipart) { /* if its going to be multi-part, add some nice headers. */ + if (mt_multipart) { /* if it's going to be multi-part, add some headers. */ static int cntr = 0; - char *fext = content_type2file_ext(ctype); + char _fext[5] = {0}, *fext = make_file_ext(msg_url, ctype, _fext); Octstr *attr = octstr_format("%06d.%s", ++cntr,fext); Octstr *cid_header_val = octstr_format("<%S>", attr);