From 1c3403cb07d41dd58d8d69ae887f9690d2785f9d Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Sun, 21 Sep 2008 22:01:46 +0000 Subject: Ticket #639: added torture tests for handling non-ASCII UTF-8 characters in SIP message elements git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2303 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/test-pjsip/msg_test.c | 22 +++++++++++++++ pjsip/src/test-pjsip/transport_test.c | 2 +- pjsip/src/test-pjsip/uri_test.c | 52 +++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/pjsip/src/test-pjsip/msg_test.c b/pjsip/src/test-pjsip/msg_test.c index 75d0e121..defcc659 100644 --- a/pjsip/src/test-pjsip/msg_test.c +++ b/pjsip/src/test-pjsip/msg_test.c @@ -806,6 +806,7 @@ static int hdr_test_via_ipv6_1(pjsip_hdr *h); static int hdr_test_via_ipv6_2(pjsip_hdr *h); static int hdr_test_via_ipv6_3(pjsip_hdr *h); static int hdr_test_retry_after1(pjsip_hdr *h); +static int hdr_test_subject_utf(pjsip_hdr *h); #define GENERIC_PARAM "p0=a;p1=\"ab:;cd\";p2=ab%3acd;p3" @@ -1022,6 +1023,13 @@ struct hdr_test_t "Retry-After", NULL, "10(Already Pending Register)", &hdr_test_retry_after1 + }, + + { + /* Non-ASCII UTF-8 characters in Subject */ + "Subject", NULL, + "\xC0\x81", + &hdr_test_subject_utf } }; @@ -1698,6 +1706,20 @@ static int hdr_test_retry_after1(pjsip_hdr *h) return 0; } +/* Subject: \xC0\x81 */ +static int hdr_test_subject_utf(pjsip_hdr *h) +{ + pjsip_subject_hdr *hdr = (pjsip_subject_hdr*)h; + + if (pj_strcmp2(&h->name, "Subject")) + return -2950; + + if (pj_strcmp2(&hdr->hvalue, "\xC0\x81")) + return -2960; + + return 0; +} + static int hdr_test(void) { unsigned i; diff --git a/pjsip/src/test-pjsip/transport_test.c b/pjsip/src/test-pjsip/transport_test.c index 769850b9..9e0ac69e 100644 --- a/pjsip/src/test-pjsip/transport_test.c +++ b/pjsip/src/test-pjsip/transport_test.c @@ -651,7 +651,7 @@ static pj_bool_t load_on_rx_request(pjsip_rx_data *rdata); static struct mod_load_test { pjsip_module mod; - pj_uint32_t next_seq; + pj_int32_t next_seq; pj_bool_t err; } mod_load = { diff --git a/pjsip/src/test-pjsip/uri_test.c b/pjsip/src/test-pjsip/uri_test.c index df99f572..100a24d0 100644 --- a/pjsip/src/test-pjsip/uri_test.c +++ b/pjsip/src/test-pjsip/uri_test.c @@ -78,6 +78,8 @@ static pjsip_uri *create_uri33( pj_pool_t *pool ); static pjsip_uri *create_uri34( pj_pool_t *pool ); static pjsip_uri *create_uri35( pj_pool_t *pool ); static pjsip_uri *create_uri36( pj_pool_t *pool ); +static pjsip_uri *create_uri37( pj_pool_t *pool ); +static pjsip_uri *create_uri38( pj_pool_t *pool ); static pjsip_uri *create_dummy( pj_pool_t *pool ); #define ERR_NOT_EQUAL -1001 @@ -332,6 +334,20 @@ struct uri_test "sip:[::1];maddr=[::01]", &create_uri36, "sip:[::1];maddr=[::01]" + }, + { + /* 37: Non-ASCII UTF-8 in display name, with quote */ + PJ_SUCCESS, + "\"\xC0\x81\" ", + &create_uri37, + "\"\xC0\x81\" " + }, + { + /* 38: Non-ASCII UTF-8 in display name, without quote */ + PJ_SUCCESS, + "\xC0\x81 ", + &create_uri38, + "\"\xC0\x81\" " } }; @@ -706,6 +722,42 @@ static pjsip_uri *create_uri36( pj_pool_t *pool ) } +/* "\"\xC0\x81\" " */ +static pjsip_uri *create_uri37( pj_pool_t *pool ) +{ + pjsip_name_addr *name; + pjsip_sip_uri *url; + + name = pjsip_name_addr_create(pool); + name->display = pj_str("\xC0\x81"); + + url = pjsip_sip_uri_create(pool, 0); + url->host = pj_str("localhost"); + + name->uri = (pjsip_uri*)url; + + return (pjsip_uri*)name; + +} + +/* "\xC0\x81 " */ +static pjsip_uri *create_uri38( pj_pool_t *pool ) +{ + pjsip_name_addr *name; + pjsip_sip_uri *url; + + name = pjsip_name_addr_create(pool); + name->display = pj_str("\xC0\x81"); + + url = pjsip_sip_uri_create(pool, 0); + url->host = pj_str("localhost"); + + name->uri = (pjsip_uri*)url; + + return (pjsip_uri*)name; + +} + static pjsip_uri *create_dummy(pj_pool_t *pool) { PJ_UNUSED_ARG(pool); -- cgit v1.2.3