libpurple/protocols/mxit/markup.c

changeset 33082
cd284b4ca152
parent 33052
df92c3d93904
parent 33058
ded93865ef42
child 33424
9919d10ee405
equal deleted inserted replaced
33078:4cfd8ccc84d4 33082:cd284b4ca152
369 { 369 {
370 char* pos; 370 char* pos;
371 int start; 371 int start;
372 unsigned int end; 372 unsigned int end;
373 int emo_ofs; 373 int emo_ofs;
374 char ii[128]; 374 char* ii;
375 char tag[64]; 375 char tag[64];
376 int* img_id; 376 int* img_id;
377 377
378 if ( mx->got_img ) { 378 if ( mx->got_img ) {
379 /* search and replace all emoticon tags with proper image tags */ 379 /* search and replace all emoticon tags with proper image tags */
387 end++; 387 end++;
388 388
389 if ( end == mx->msg->len ) /* end of emoticon tag not found */ 389 if ( end == mx->msg->len ) /* end of emoticon tag not found */
390 break; 390 break;
391 391
392 memset( ii, 0x00, sizeof( ii ) ); 392 ii = g_strndup(&mx->msg->str[emo_ofs], end - emo_ofs);
393 memcpy( ii, &mx->msg->str[emo_ofs], end - emo_ofs );
394 393
395 /* remove inline image tag */ 394 /* remove inline image tag */
396 g_string_erase( mx->msg, start, ( end - start ) + 1 ); 395 g_string_erase( mx->msg, start, ( end - start ) + 1 );
397 396
398 /* find the image entry */ 397 /* find the image entry */
406 g_snprintf( tag, sizeof( tag ), 405 g_snprintf( tag, sizeof( tag ),
407 "<img src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%i\">", 406 "<img src=\"" PURPLE_STORED_IMAGE_PROTOCOL "%i\">",
408 *img_id ); 407 *img_id );
409 g_string_insert( mx->msg, start, tag ); 408 g_string_insert( mx->msg, start, tag );
410 } 409 }
410
411 g_free(ii);
411 } 412 }
412 } 413 }
413 414
414 #ifdef MXIT_DEBUG_MARKUP 415 #ifdef MXIT_DEBUG_MARKUP
415 purple_debug_info( MXIT_PLUGIN_ID, "Markup RX (converted): '%s'\n", mx->msg->str ); 416 purple_debug_info( MXIT_PLUGIN_ID, "Markup RX (converted): '%s'\n", mx->msg->str );

mercurial