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
|
@ -1012,7 +1012,22 @@ static int fixup_msg(MmsMsg *m, Octstr *from)
|
|||
http_header_add(m->headers, "MessageID", "00000");
|
||||
else
|
||||
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;
|
||||
|
|
|
@ -726,12 +726,12 @@ void unbase64_mimeparts(MIMEEntity *m)
|
|||
octstr_destroy(te);
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
static int gw_isprint(int c)
|
||||
|
||||
int _mms_gw_isprint(int c)
|
||||
{
|
||||
return isprint(c) || isspace(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Change content coding for mime entities that need it. */
|
||||
void base64_mimeparts(MIMEEntity *m)
|
||||
|
@ -748,7 +748,7 @@ void base64_mimeparts(MIMEEntity *m)
|
|||
if (ctype && !te
|
||||
#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
|
||||
) {
|
||||
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... */
|
||||
extern MIMEEntity *mime_entity_duplicate(MIMEEntity *m);
|
||||
|
||||
/* Returns true if the character is printable or space */
|
||||
int _mms_gw_isprint(int c);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue