diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index 10131dc..204a3ba 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,6 @@ +2008-08-19 P. A. Bagyenda + * Fix for Content-ID header in mmsbox (thanks to Vincent Chavanis ) + * Typo fix thanks to Martin Atukunda (matlads@dsmagic.com) 2008-08-14 P. A. Bagyenda * Mmsbox will now queue message to email (outgoing) if recipient looks like an email address 2008-08-08 P. A. Bagyenda diff --git a/mbuni/mmlib/mms_util.c b/mbuni/mmlib/mms_util.c index 01290a3..f16b500 100644 --- a/mbuni/mmlib/mms_util.c +++ b/mbuni/mmlib/mms_util.c @@ -1364,6 +1364,23 @@ static struct { {NULL, NULL} }; +/* Some of Web languages used for generating content, but can't be a content itself. */ +static struct { + char *language, *file_ext; +} l_exts[] = { + {"Perl", "pl"}, + {"Php", "php"}, + {"Python", "py"}, + {"Common Gateway Interface", "cgi"}, + {"Active Server Page", "asp"}, + {"Java Server Page", "jsp"}, + {"Ruby on Rails", "rb"}, + {"Tool Command Language", "tcl"}, + {"Shell Command Language", "sh"}, + {"Executables", "exe"}, + {NULL, NULL} +}; + Octstr *filename2content_type(char *fname) { char *p = strrchr(fname, '.'); @@ -1379,7 +1396,12 @@ Octstr *filename2content_type(char *fname) static char *content_type2file_ext(Octstr *ctype) { - int i; + int i, j; + + /* Take the first value, expecting content-type! */ + if ((j = octstr_search_char(ctype, ';', 0)) != -1) + octstr_delete(ctype, j, octstr_len(ctype)); + for (i = 0; exts[i].file_ext; i++) if (octstr_str_case_compare(ctype, exts[i].ctype) == 0) return exts[i].file_ext; @@ -1389,6 +1411,7 @@ static char *content_type2file_ext(Octstr *ctype) char *make_file_ext(Octstr *url, Octstr *ctype, char fext[5]) { + int i; fext[0] = 0; if (url) { HTTPURLParse *h = parse_url(url); @@ -1402,7 +1425,13 @@ char *make_file_ext(Octstr *url, Octstr *ctype, char fext[5]) strncpy(fext, p+1, 4); /* max length of 4. */ http_urlparse_destroy(h); - if (fext[0]) return fext; + + for (i = 0; l_exts[i].file_ext; i++) + if (strcasecmp(fext, l_exts[i].file_ext) == 0) + return content_type2file_ext(ctype); + + if (fext[0]) + return fext; } done: return content_type2file_ext(ctype);