Changeset 3340


Ignore:
Timestamp:
Oct 13, 2010 9:41:37 AM (13 years ago)
Author:
bennylp
Message:

Fixed #1147: Bug in parsing multipart message bodies (thanks Johan Lantz for the report)

Location:
pjproject/trunk/pjsip
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_msg.h

    r3241 r3340  
    547547 * @param mt1           The first media type. 
    548548 * @param mt2           The second media type. 
     549 * @param cmp_param     Specify how to compare the media type parameters: 
     550 *                       - 0: do not compare parameters 
     551 *                       - 1: compare parameters but ignore parameters that 
     552 *                            only appear in one of the media type. 
     553 *                       - 2: compare the parameters. 
    549554 * 
    550555 * @return              Zero if both media types are equal, -1 if mt1 < mt2, 
     
    552557 */ 
    553558PJ_DECL(int) pjsip_media_type_cmp(const pjsip_media_type *mt1, 
    554                                   const pjsip_media_type *mt2); 
     559                                  const pjsip_media_type *mt2, 
     560                                  int cmp_param); 
    555561 
    556562/** 
  • pjproject/trunk/pjsip/src/pjsip/sip_msg.c

    r3301 r3340  
    646646 */ 
    647647PJ_DEF(int) pjsip_media_type_cmp( const pjsip_media_type *mt1, 
    648                                   const pjsip_media_type *mt2) 
     648                                  const pjsip_media_type *mt2, 
     649                                  pj_bool_t cmp_param) 
    649650{ 
    650651    int rc; 
     
    658659    if (rc) return rc; 
    659660 
    660     rc = pjsip_param_cmp(&mt1->param, &mt2->param, 0); 
     661    if (cmp_param) { 
     662        rc = pjsip_param_cmp(&mt1->param, &mt2->param, (cmp_param==1)); 
     663    } 
    661664 
    662665    return rc; 
  • pjproject/trunk/pjsip/src/pjsip/sip_multipart.c

    r3255 r3340  
    397397 
    398398    while (part != &m_data->part_head) { 
    399         if (pjsip_media_type_cmp(&part->body->content_type, content_type)==0) 
     399        if (pjsip_media_type_cmp(&part->body->content_type, 
     400                                 content_type, 0)==0) 
     401        { 
    400402            return part; 
     403        } 
    401404        part = part->next; 
    402405    } 
  • pjproject/trunk/pjsip/src/pjsip/sip_parser.c

    r3243 r3340  
    18571857    while (*scanner->curptr == ';') { 
    18581858        pjsip_param *param = PJ_POOL_ALLOC_T(ctx->pool, pjsip_param); 
    1859         int_parse_param(scanner, ctx->pool, &param->name, &param->value, 0); 
     1859        int_parse_param(scanner, ctx->pool, &param->name, &param->value, 
     1860                        PJSIP_PARSE_REMOVE_QUOTE); 
    18601861        pj_list_push_back(&hdr->media.param, param); 
    18611862    } 
  • pjproject/trunk/pjsip/src/test/multipart_test.c

    r3244 r3340  
    117117        init_media_type(&mt, h_content_type, h_content_subtype, boundary); 
    118118 
    119         if (pjsip_media_type_cmp(&ctype_hdr->media, &mt) != 0) 
     119        if (pjsip_media_type_cmp(&ctype_hdr->media, &mt, 2) != 0) 
    120120            return -20; 
    121121 
     
    154154    /* Check content-type: "multipart/mixed;boundary=12345" */ 
    155155    init_media_type(&mt, "multipart", "mixed", "12345"); 
    156     if (pjsip_media_type_cmp(&body->content_type, &mt) != 0) 
     156    if (pjsip_media_type_cmp(&body->content_type, &mt, 2) != 0) 
    157157        return -200; 
    158158 
Note: See TracChangeset for help on using the changeset viewer.