bug fix: insert content-type header in message if missing, try and guess what it should be by examining message body
This commit is contained in:
parent
025c3f507b
commit
683948a174
|
@ -1013,6 +1013,21 @@ static int fixup_msg(MmsMsg *m, Octstr *from)
|
||||||
else
|
else
|
||||||
octstr_destroy(s);
|
octstr_destroy(s);
|
||||||
|
|
||||||
|
/* check for content-type. */
|
||||||
|
if ((s = http_header_value(m->headers, octstr_imm("Content-Type"))) == NULL) {
|
||||||
|
char *ctype;
|
||||||
|
if (m->body.s == NULL ||
|
||||||
|
(!m->ismultipart &&
|
||||||
|
octstr_check_range(m->body.s, 0,
|
||||||
|
octstr_len(m->body.s), _mms_gw_isprint) == 0))
|
||||||
|
ctype = "application/octet-stream";
|
||||||
|
else if (m->ismultipart)
|
||||||
|
ctype = "application/vnd.wap.multipart.mixed";
|
||||||
|
else
|
||||||
|
ctype = "text/plain";
|
||||||
|
http_header_add(m->headers, "Content-Type", ctype);
|
||||||
|
} else
|
||||||
|
octstr_destroy(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -726,12 +726,12 @@ void unbase64_mimeparts(MIMEEntity *m)
|
||||||
octstr_destroy(te);
|
octstr_destroy(te);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 1
|
|
||||||
static int gw_isprint(int c)
|
int _mms_gw_isprint(int c)
|
||||||
{
|
{
|
||||||
return isprint(c) || isspace(c);
|
return isprint(c) || isspace(c);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Change content coding for mime entities that need it. */
|
/* Change content coding for mime entities that need it. */
|
||||||
void base64_mimeparts(MIMEEntity *m)
|
void base64_mimeparts(MIMEEntity *m)
|
||||||
|
@ -748,7 +748,7 @@ void base64_mimeparts(MIMEEntity *m)
|
||||||
if (ctype && !te
|
if (ctype && !te
|
||||||
#if 1
|
#if 1
|
||||||
&&
|
&&
|
||||||
(m->body && octstr_check_range(m->body, 0, octstr_len(m->body), gw_isprint) == 0)
|
(m->body && octstr_check_range(m->body, 0, octstr_len(m->body), _mms_gw_isprint) == 0)
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
octstr_binary_to_base64(m->body);
|
octstr_binary_to_base64(m->body);
|
||||||
|
|
|
@ -206,4 +206,7 @@ int mm_lockfile(int fd, char *fname, int shouldblock);
|
||||||
|
|
||||||
/* This should be elsewhere, but it isn't, so we do it here... */
|
/* This should be elsewhere, but it isn't, so we do it here... */
|
||||||
extern MIMEEntity *mime_entity_duplicate(MIMEEntity *m);
|
extern MIMEEntity *mime_entity_duplicate(MIMEEntity *m);
|
||||||
|
|
||||||
|
/* Returns true if the character is printable or space */
|
||||||
|
int _mms_gw_isprint(int c);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue