comparison mcabber/mcabber/commands.c @ 1861:81822de0edf6

Fix a potential encoding issue on non-UTF8 systems
author Mikael Berthe <mikael@lilotux.net>
date Sat, 03 Apr 2010 19:12:20 +0200
parents 5492b87ba9d0
children ad1f7e7c2745
comparison
equal deleted inserted replaced
1860:5492b87ba9d0 1861:81822de0edf6
1494 static void do_say_to(char *arg) 1494 static void do_say_to(char *arg)
1495 { 1495 {
1496 char **paramlst; 1496 char **paramlst;
1497 char *fjid, *msg; 1497 char *fjid, *msg;
1498 char *file = NULL; 1498 char *file = NULL;
1499 char *xfjid = NULL;
1500 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET; 1499 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET;
1501 bool quiet = FALSE; 1500 bool quiet = FALSE;
1502 bool expandfjid = FALSE; 1501 bool expandfjid = FALSE;
1503 1502
1504 if (!xmpp_is_online()) { 1503 if (!xmpp_is_online()) {
1559 if (!fjid) { 1558 if (!fjid) {
1560 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); 1559 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID.");
1561 free_arg_lst(paramlst); 1560 free_arg_lst(paramlst);
1562 return; 1561 return;
1563 } 1562 }
1564 if (expandfjid) { 1563 if (expandfjid && *res) {
1565 xfjid = g_strdup_printf("%s%c%s", fjid, JID_RESOURCE_SEPARATOR, res); 1564 char *res_utf8 = to_utf8(res);
1566 fjid = xfjid; 1565 fjid = g_strdup_printf("%s%c%s", fjid, JID_RESOURCE_SEPARATOR, res_utf8);
1567 } 1566 g_free(res_utf8);
1568 } else if (check_jid_syntax(fjid)) { 1567 }
1568 } else
1569 fjid = to_utf8(fjid);
1570
1571 if (check_jid_syntax(fjid)) {
1569 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); 1572 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID.");
1570 free_arg_lst(paramlst); 1573 free_arg_lst(paramlst);
1571 return; 1574 g_free(fjid);
1572 } 1575 return;
1573 1576 }
1574 fjid = to_utf8(fjid); 1577
1575 if (!file) { 1578 if (!file) {
1576 msg = to_utf8(msg); 1579 msg = to_utf8(msg);
1577 } else { 1580 } else {
1578 char *filename_xp; 1581 char *filename_xp;
1579 if (msg) 1582 if (msg)
1584 g_free(file); 1587 g_free(file);
1585 } 1588 }
1586 1589
1587 send_message_to(fjid, msg, NULL, msg_type, quiet); 1590 send_message_to(fjid, msg, NULL, msg_type, quiet);
1588 1591
1589 g_free(xfjid);
1590 g_free(fjid); 1592 g_free(fjid);
1591 g_free(msg); 1593 g_free(msg);
1592 free_arg_lst(paramlst); 1594 free_arg_lst(paramlst);
1593 } 1595 }
1594 1596