libpurple/protocols/mxit/markup.c

branch
release-2.x.y
changeset 33058
ded93865ef42
parent 31716
8174ce8652aa
child 33082
cd284b4ca152
child 33188
15c1814de8c2
child 33553
b31098549396
equal deleted inserted replaced
33048:a5a5365dbaa5 33058:ded93865ef42
359 { 359 {
360 char* pos; 360 char* pos;
361 int start; 361 int start;
362 unsigned int end; 362 unsigned int end;
363 int emo_ofs; 363 int emo_ofs;
364 char ii[128]; 364 char* ii;
365 char tag[64]; 365 char tag[64];
366 int* img_id; 366 int* img_id;
367 367
368 if ( mx->got_img ) { 368 if ( mx->got_img ) {
369 /* search and replace all emoticon tags with proper image tags */ 369 /* search and replace all emoticon tags with proper image tags */
377 end++; 377 end++;
378 378
379 if ( end == mx->msg->len ) /* end of emoticon tag not found */ 379 if ( end == mx->msg->len ) /* end of emoticon tag not found */
380 break; 380 break;
381 381
382 memset( ii, 0x00, sizeof( ii ) ); 382 ii = g_strndup(&mx->msg->str[emo_ofs], end - emo_ofs);
383 memcpy( ii, &mx->msg->str[emo_ofs], end - emo_ofs );
384 383
385 /* remove inline image tag */ 384 /* remove inline image tag */
386 g_string_erase( mx->msg, start, ( end - start ) + 1 ); 385 g_string_erase( mx->msg, start, ( end - start ) + 1 );
387 386
388 /* find the image entry */ 387 /* find the image entry */
394 else { 393 else {
395 /* insert img tag */ 394 /* insert img tag */
396 g_snprintf( tag, sizeof( tag ), "<img id=\"%i\">", *img_id ); 395 g_snprintf( tag, sizeof( tag ), "<img id=\"%i\">", *img_id );
397 g_string_insert( mx->msg, start, tag ); 396 g_string_insert( mx->msg, start, tag );
398 } 397 }
398
399 g_free(ii);
399 } 400 }
400 } 401 }
401 402
402 #ifdef MXIT_DEBUG_MARKUP 403 #ifdef MXIT_DEBUG_MARKUP
403 purple_debug_info( MXIT_PLUGIN_ID, "Markup RX (converted): '%s'\n", mx->msg->str ); 404 purple_debug_info( MXIT_PLUGIN_ID, "Markup RX (converted): '%s'\n", mx->msg->str );

mercurial