added normalisation of message internal addresses on mm1
This commit is contained in:
parent
fbbec2877b
commit
d9be1198a5
|
@ -4,6 +4,7 @@
|
|||
*.patch
|
||||
*.lo
|
||||
*.o
|
||||
.gdb_history
|
||||
mpeg2dec-*.tar.gz
|
||||
Makefile
|
||||
Makefile.in
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
2008-05-05 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Normalisation of numbers inside messages as well
|
||||
* Added strip-prefixes config parameter
|
||||
2008-04-18 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Various memory leak fixes (thanks to Monachin Eric @ Skycore)
|
||||
|
|
|
@ -33,7 +33,8 @@ struct MmsMsg {
|
|||
|
||||
|
||||
static int encode_msgheaders(Octstr *os, List *hdrs);
|
||||
static int decode_msgheaders(ParseContext *context, List *hdr, Octstr *from, int stop_on_ctype);
|
||||
static int decode_msgheaders(ParseContext *context, List *hdr, Octstr *from, int stop_on_ctype,
|
||||
char *unified_prefix, List *strip_prefixes);
|
||||
|
||||
|
||||
static inline void pack_short_integer(Octstr *s, int ch)
|
||||
|
@ -267,8 +268,9 @@ static Octstr *decode_encoded_string_value(int ret, ParseContext *context, unsig
|
|||
* useful for unpacking msg type
|
||||
*/
|
||||
static int mms_unpack_well_known_field(List *unpacked, int field_type,
|
||||
ParseContext *context,
|
||||
Octstr *xfrom, int msgtype)
|
||||
ParseContext *context,
|
||||
Octstr *xfrom, int msgtype,
|
||||
char *unified_prefix, List *strip_prefixes)
|
||||
{
|
||||
int val, ret;
|
||||
unsigned char *hname = NULL;
|
||||
|
@ -296,7 +298,8 @@ static int mms_unpack_well_known_field(List *unpacked, int field_type,
|
|||
case MMS_HEADER_BCC:
|
||||
if (ret == WSP_FIELD_VALUE_DATA)
|
||||
decoded = decode_encoded_string_value(ret, context, hname);
|
||||
|
||||
if (decoded)
|
||||
_mms_fixup_address(&decoded, unified_prefix, strip_prefixes, 1);
|
||||
if (decoded == NULL || mms_validate_address(decoded))
|
||||
warning(0, "Faulty address [%s] format in field %s!",
|
||||
octstr_get_cstr(decoded), hname);
|
||||
|
@ -464,14 +467,16 @@ static int mms_unpack_well_known_field(List *unpacked, int field_type,
|
|||
else {
|
||||
int n = parse_get_char(context);
|
||||
|
||||
if (n == 0x80) { /* Address present. */
|
||||
if (n == 0x80) /* Address present. */
|
||||
decoded = decode_encoded_string_value(-1,context, hname);
|
||||
if (decoded == NULL ||
|
||||
mms_validate_address(decoded))
|
||||
warning(0, "Faulty address [%s] format in field %s!",
|
||||
octstr_get_cstr(decoded), hname);
|
||||
} else /* Insert address. */
|
||||
else /* Insert address. */
|
||||
decoded = octstr_duplicate(xfrom);
|
||||
|
||||
if (decoded)
|
||||
_mms_fixup_address(&decoded, unified_prefix, strip_prefixes, 1);
|
||||
if (decoded == NULL || mms_validate_address(decoded))
|
||||
warning(0, "Faulty address [%s] format in field %s!",
|
||||
octstr_get_cstr(decoded), hname);
|
||||
}
|
||||
break;
|
||||
case MMS_HEADER_PREVIOUSLY_SENT_BY:
|
||||
|
@ -603,7 +608,8 @@ static int mms_unpack_well_known_field(List *unpacked, int field_type,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int decode_msgheaders(ParseContext *context, List *hdrs, Octstr *from, int stop_on_ctype)
|
||||
static int decode_msgheaders(ParseContext *context, List *hdrs, Octstr *from,
|
||||
int stop_on_ctype, char *unified_prefixes, List *strip_prefixes)
|
||||
{
|
||||
int fcont = 1;
|
||||
int msgtype = 0;
|
||||
|
@ -616,7 +622,8 @@ static int decode_msgheaders(ParseContext *context, List *hdrs, Octstr *from, in
|
|||
int val = 0;
|
||||
|
||||
if (byte >= 0x80)
|
||||
val = mms_unpack_well_known_field(hdrs, byte&0x7f, context, from, msgtype);
|
||||
val = mms_unpack_well_known_field(hdrs, byte&0x7f, context, from, msgtype,
|
||||
unified_prefixes, strip_prefixes);
|
||||
else {
|
||||
parse_skip(context, -1); /* Go back a bit. */
|
||||
wsp_unpack_app_header(hdrs, context);
|
||||
|
@ -1087,7 +1094,7 @@ mms_encoding mms_message_enc(MmsMsg *msg)
|
|||
return msg->enc;
|
||||
}
|
||||
|
||||
MmsMsg *mms_frombinary(Octstr *msg, Octstr *from)
|
||||
MmsMsg *mms_frombinary_ex(Octstr *msg, Octstr *from, char *unified_prefix, List *strip_prefixes)
|
||||
{
|
||||
int res = 0;
|
||||
MmsMsg _m = {0}, *m = NULL;
|
||||
|
@ -1101,7 +1108,7 @@ MmsMsg *mms_frombinary(Octstr *msg, Octstr *from)
|
|||
mms_strings_init(); /* Just in case. */
|
||||
|
||||
_m.headers = gwlist_create();
|
||||
decode_msgheaders(p, _m.headers, from, 1);
|
||||
decode_msgheaders(p, _m.headers, from, 1, unified_prefix, strip_prefixes);
|
||||
|
||||
if (_m.headers == NULL ||
|
||||
gwlist_len(_m.headers) == 0)
|
||||
|
|
|
@ -32,7 +32,9 @@ extern int mms_validate_address(Octstr *s);
|
|||
* Takes from param which is put in if insert-address is requested.
|
||||
* NOTE: function may modify 'msg' argument as it parses.
|
||||
*/
|
||||
extern MmsMsg *mms_frombinary(Octstr *msg, Octstr *from);
|
||||
extern MmsMsg *mms_frombinary_ex(Octstr *msg, Octstr *from, char *unified_prefix, List *strip_prefixes);
|
||||
|
||||
#define mms_frombinary(msg, from) mms_frombinary_ex((msg), (from), NULL, NULL)
|
||||
|
||||
/*
|
||||
* mms_tobinary: Return binary encoded Mms message
|
||||
|
|
|
@ -510,7 +510,8 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
|
|||
goto done;
|
||||
}
|
||||
|
||||
m = mms_frombinary(h->body, h->client_addr ? h->client_addr : octstr_imm("anon@anon"));
|
||||
m = mms_frombinary_ex(h->body, h->client_addr ? h->client_addr : octstr_imm("anon@anon"),
|
||||
octstr_get_cstr(settings->unified_prefix), settings->strip_prefixes);
|
||||
|
||||
if (!m) {
|
||||
http_header_add(rh, "Content-Type", "text/plain");
|
||||
|
@ -556,8 +557,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
|
|||
|
||||
mms_collect_envdata_from_msgheaders(mh, &to, &subject, &otransid, &expiryt,
|
||||
&deliveryt, settings->default_msgexpiry,
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
NULL, NULL); /* already normalized. */
|
||||
|
||||
if (!h->client_addr) {
|
||||
mresp = mms_sendconf("Error-sending-address-unresolved", "None",
|
||||
|
@ -681,8 +681,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
|
|||
|
||||
mms_collect_envdata_from_msgheaders(mh, &to, &subject, &otransid, &expiryt,
|
||||
&deliveryt, settings->default_msgexpiry,
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
NULL, NULL);
|
||||
|
||||
if (!h->client_addr) {
|
||||
mresp = mms_sendconf("Error-sending-address-unresolved", "None", octstr_get_cstr(otransid),1,
|
||||
|
@ -1037,8 +1036,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
|
|||
|
||||
mms_collect_envdata_from_msgheaders(mh, &to, NULL, NULL, NULL, NULL,
|
||||
settings->default_msgexpiry,
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
NULL, NULL);
|
||||
|
||||
x = settings->qfs->mms_queue_add(from, to, NULL, NULL, NULL, time(NULL),
|
||||
time(NULL) + settings->default_msgexpiry,
|
||||
|
@ -1792,8 +1790,7 @@ static void mm7eaif_dispatch(MmsHTTPClientInfo *h)
|
|||
*/
|
||||
mms_collect_envdata_from_msgheaders(mh, &to, &subject, &otransid, &expiryt,
|
||||
&deliveryt, settings->default_msgexpiry,
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
NULL, NULL);
|
||||
|
||||
|
||||
if ((hto = http_header_find_all(h->headers, "X-NOKIA-MMSC-To")) != NULL &&
|
||||
|
|
|
@ -137,7 +137,9 @@ int main(int argc, char *argv[])
|
|||
mime_entity_destroy(mime);
|
||||
}
|
||||
} else
|
||||
m = mms_frombinary(data, from ? from : octstr_imm("anon@anon"));
|
||||
m = mms_frombinary_ex(data, from ? from : octstr_imm("anon@anon"),
|
||||
octstr_get_cstr(settings->unified_prefix),
|
||||
settings->strip_prefixes);
|
||||
if (m)
|
||||
mms_msgdump(m,1);
|
||||
msize = octstr_len(data);
|
||||
|
|
Loading…
Reference in New Issue