1
0
Fork 0

Misc fixes

This commit is contained in:
bagyenda 2008-08-19 06:45:48 +00:00
parent b477dd843c
commit 2ff5dabb9e
2 changed files with 34 additions and 2 deletions

View File

@ -1,3 +1,6 @@
2008-08-19 P. A. Bagyenda <bagyenda@dsmagic.com>
* Fix for Content-ID header in mmsbox (thanks to Vincent Chavanis <v.chavanis@telemaque.fr>)
* Typo fix thanks to Martin Atukunda (matlads@dsmagic.com)
2008-08-14 P. A. Bagyenda <bagyenda@dsmagic.com>
* Mmsbox will now queue message to email (outgoing) if recipient looks like an email address
2008-08-08 P. A. Bagyenda <bagyenda@dsmagic.com>

View File

@ -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);