Mercurial > pidgin
changeset 10732:c4cb90065e1d
[gaim-migrate @ 12334]
"gaim_escape_html (according to Ethan) predates
g_markup_escape_text. Current code in Gaim uses both
functions. This patch removes gaim_escape_html from the
API and replaces all calls in the Gaim tree with
g_markup_escape_text. I included a ChangeLog.API note.
As far as I can tell, this still works perfectly.
This is obviously intended for HEAD only, as it removes a
public function." --rlaager
this was discussed extensively this morning
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 26 Mar 2005 02:43:49 +0000 |
parents | 783ca1f1ebdb |
children | d5f2ebf79429 |
files | plugins/ChangeLog.API src/gtkconv.c src/gtkimhtml.c src/gtkimhtmltoolbar.c src/gtknotify.c src/gtksavedstatuses.c src/log.c src/protocols/gg/gg.c src/protocols/irc/cmds.c src/protocols/irc/irc.c src/protocols/irc/msgs.c src/protocols/jabber/chat.c src/protocols/jabber/message.c src/protocols/msn/msn.c src/protocols/msn/switchboard.c src/protocols/napster/napster.c src/protocols/oscar/oscar.c src/protocols/silc/chat.c src/protocols/silc/ops.c src/protocols/silc/silc.c src/protocols/yahoo/yahoo.c src/protocols/zephyr/zephyr.c src/util.c src/util.h |
diffstat | 24 files changed, 54 insertions(+), 95 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChangeLog.API Sat Mar 26 01:20:31 2005 +0000 +++ b/plugins/ChangeLog.API Sat Mar 26 02:43:49 2005 +0000 @@ -20,6 +20,8 @@ list of the given account. * Changed: gaim_blist_node_action_new, added a fourth argument, a GList of GaimBlistNodeActions to be created as a submenu of the item. + * Removed: gaim_escape_html(const char *html) (use + g_markup_escape_text(html, -1) instead) Signals: * Changed: "received-im-msg and "received-chat-msg" to match, both
--- a/src/gtkconv.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/gtkconv.c Sat Mar 26 02:43:49 2005 +0000 @@ -307,7 +307,7 @@ if (!g_ascii_strcasecmp(args[0], "version")) { tmp = g_strdup_printf(_("me is using Gaim v%s."), VERSION); - markup = gaim_escape_html(tmp); + markup = g_markup_escape_text(tmp, -1); status = gaim_cmd_do_command(conv, tmp, markup, error); @@ -5349,7 +5349,7 @@ { char *html_title,*label; - html_title = gaim_escape_html(title); + html_title = g_markup_escape_text(title, -1); label = g_strdup_printf("<span color=\"%s\">%s</span>", color, html_title);
--- a/src/gtkimhtml.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/gtkimhtml.c Sat Mar 26 02:43:49 2005 +0000 @@ -793,7 +793,7 @@ if (text == NULL) return; - tmp = gaim_escape_html(text); + tmp = g_markup_escape_text(text, -1); imhtml_paste_insert(data, tmp, TRUE); g_free(tmp); } @@ -1481,7 +1481,7 @@ gaim_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); return; } else { - char *tmp = gaim_escape_html(text); + char *tmp = g_markup_escape_text(text, -1); gtk_imhtml_insert_html_at_iter(imhtml, tmp, 0, &iter); g_free(tmp); }
--- a/src/gtkimhtmltoolbar.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/gtkimhtmltoolbar.c Sat Mar 26 02:43:49 2005 +0000 @@ -591,7 +591,7 @@ char *smiley_text, *escaped_smiley; smiley_text = g_object_get_data(G_OBJECT(widget), "smiley_text"); - escaped_smiley = gaim_escape_html(smiley_text); + escaped_smiley = g_markup_escape_text(smiley_text, -1); gtk_imhtml_insert_smiley(GTK_IMHTML(toolbar->imhtml), GTK_IMHTML(toolbar->imhtml)->protocol_name,
--- a/src/gtknotify.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/gtknotify.c Sat Mar 26 02:43:49 2005 +0000 @@ -593,7 +593,7 @@ GError *error = NULL; gint ret = 0; - escaped = gaim_escape_html(command); + escaped = g_markup_escape_text(command, -1); gaim_debug_misc("gtknotify", "Executing %s\n", escaped); if (!gaim_program_is_valid(command))
--- a/src/gtksavedstatuses.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/gtksavedstatuses.c Sat Mar 26 02:43:49 2005 +0000 @@ -180,7 +180,7 @@ gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1); - title_escaped = gaim_escape_html(title); + title_escaped = g_markup_escape_text(title, -1); buf = g_strdup_printf(_("Are you sure you want to delete %s?"), title_escaped); free(title_escaped); gaim_request_action(NULL, NULL, buf, NULL, 0, title, 2,
--- a/src/log.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/log.c Sat Mar 26 02:43:49 2005 +0000 @@ -795,7 +795,7 @@ else minus_header = g_strdup(minus_header + 1); g_free(read); - minus_header2 = gaim_escape_html(minus_header); + minus_header2 = g_markup_escape_text(minus_header, -1); g_free(minus_header); return minus_header2; }
--- a/src/protocols/gg/gg.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/gg/gg.c Sat Mar 26 02:43:49 2005 +0000 @@ -1,6 +1,6 @@ /* * gaim - Gadu-Gadu Protocol Plugin - * $Id: gg.c 12199 2005-03-07 02:19:09Z deryni9 $ + * $Id: gg.c 12334 2005-03-26 02:43:49Z lschiere $ * * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> * @@ -527,7 +527,7 @@ break; imsg = charset_convert(e->event.msg.message, "CP1250", "UTF-8"); gaim_str_strip_cr(imsg); - jmsg = gaim_escape_html(imsg); + jmsg = g_markup_escape_text(imsg, -1); serv_got_im(gc, user, jmsg, 0, e->event.msg.time); g_free(imsg); g_free(jmsg);
--- a/src/protocols/irc/cmds.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/irc/cmds.c Sat Mar 26 02:43:49 2005 +0000 @@ -456,7 +456,7 @@ if (topic) { char *tmp, *tmp2; - tmp = gaim_escape_html(topic); + tmp = g_markup_escape_text(topic, -1); tmp2 = gaim_markup_linkify(tmp); buf = g_strdup_printf(_("current topic is: %s"), tmp2); g_free(tmp);
--- a/src/protocols/irc/irc.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/irc/irc.c Sat Mar 26 02:43:49 2005 +0000 @@ -614,7 +614,7 @@ irc_cmd_privmsg(irc, "msg", NULL, args); - tmp = gaim_escape_html(what); + tmp = g_markup_escape_text(what, -1); serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, tmp, time(NULL)); g_free(tmp); return 0;
--- a/src/protocols/irc/msgs.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/irc/msgs.c Sat Mar 26 02:43:49 2005 +0000 @@ -305,7 +305,7 @@ } /* If this is an interactive update, print it out */ - tmp = gaim_escape_html(topic); + tmp = g_markup_escape_text(topic, -1); tmp2 = gaim_markup_linkify(tmp); g_free(tmp); if (!strcmp(name, "topic")) { @@ -920,7 +920,7 @@ return; } - msg = gaim_escape_html(tmp); + msg = g_markup_escape_text(tmp, -1); g_free(tmp); tmp = irc_mirc2html(msg);
--- a/src/protocols/jabber/chat.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/jabber/chat.c Sat Mar 26 02:43:49 2005 +0000 @@ -584,7 +584,7 @@ char *buf, *tmp, *tmp2; if(cur) { - tmp = gaim_escape_html(cur); + tmp = g_markup_escape_text(cur, -1); tmp2 = gaim_markup_linkify(tmp); buf = g_strdup_printf(_("current topic is: %s"), tmp2); g_free(tmp);
--- a/src/protocols/jabber/message.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/jabber/message.c Sat Mar 26 02:43:49 2005 +0000 @@ -172,7 +172,7 @@ jm->subject); if(!jm->xhtml && !jm->body) { char *msg, *tmp, *tmp2; - tmp = gaim_escape_html(jm->subject); + tmp = g_markup_escape_text(jm->subject, -1); tmp2 = gaim_markup_linkify(tmp); if(jid->resource) msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2);
--- a/src/protocols/msn/msn.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/msn/msn.c Sat Mar 26 02:43:49 2005 +0000 @@ -751,7 +751,7 @@ * we'll fake like we received it ;) */ body_str = msn_message_to_string(msg); - body_enc = gaim_escape_html(body_str); + body_enc = g_markup_escape_text(body_str, -1); g_free(body_str); format = msn_message_get_attr(msg, "X-MMS-IM-Format");
--- a/src/protocols/msn/switchboard.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/msn/switchboard.c Sat Mar 26 02:43:49 2005 +0000 @@ -407,7 +407,7 @@ } body_str = msn_message_to_string(msg); - body_enc = gaim_escape_html(body_str); + body_enc = g_markup_escape_text(body_str, -1); g_free(body_str); format = msn_message_get_attr(msg, "X-MMS-IM-Format"); @@ -640,9 +640,9 @@ account = cmdproc->session->account; if ((b = gaim_find_buddy(account, user)) != NULL) - username = gaim_escape_html(gaim_buddy_get_alias(b)); + username = g_markup_escape_text(gaim_buddy_get_alias(b), -1); else - username = gaim_escape_html(user); + username = g_markup_escape_text(user, -1); str = g_strdup_printf(_("%s has closed the conversation window."), username); @@ -811,7 +811,7 @@ body = msn_message_get_bin_data(msg, &body_len); body_str = g_strndup(body, body_len); - body_enc = gaim_escape_html(body_str); + body_enc = g_markup_escape_text(body_str, -1); g_free(body_str); passport = msg->remote_user;
--- a/src/protocols/napster/napster.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/napster/napster.c Sat Mar 26 02:43:49 2005 +0000 @@ -293,7 +293,7 @@ case 205: /* MSG_CLIENT_PRIVMSG */ res = g_strsplit(buf, " ", 2); - buf2 = gaim_escape_html(res[1]); + buf2 = g_markup_escape_text(res[1], -1); serv_got_im(gc, res[0], buf2, 0, time(NULL)); g_free(buf2); g_strfreev(res); @@ -354,7 +354,7 @@ case 404: /* MSG_SERVER_NOSUCH */ /* abused by opennap servers to broadcast stuff */ - buf2 = gaim_escape_html(buf); + buf2 = g_markup_escape_text(buf, -1); serv_got_im(gc, "server", buf2, 0, time(NULL)); g_free(buf2); break; @@ -409,20 +409,20 @@ case 621: case 622: /* MSG_CLIENT_MOTD */ /* also replaces MSG_SERVER_MOTD, so we should display it */ - buf2 = gaim_escape_html(buf); + buf2 = g_markup_escape_text(buf, -1); serv_got_im(gc, "motd", buf2, 0, time(NULL)); g_free(buf2); break; case 627: /* MSG_CLIENT_WALLOP */ /* abused by opennap server maintainers to broadcast stuff */ - buf2 = gaim_escape_html(buf); + buf2 = g_markup_escape_text(buf, -1); serv_got_im(gc, "wallop", buf2, 0, time(NULL)); g_free(buf2); break; case 628: /* MSG_CLIENT_ANNOUNCE */ - buf2 = gaim_escape_html(buf); + buf2 = g_markup_escape_text(buf, -1); serv_got_im(gc, "announce", buf2, 0, time(NULL)); g_free(buf); break;
--- a/src/protocols/oscar/oscar.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/oscar/oscar.c Sat Mar 26 02:43:49 2005 +0000 @@ -3411,7 +3411,7 @@ */ if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ - gchar *tmp2 = gaim_escape_html(tmp); + gchar *tmp2 = g_markup_escape_text(tmp, -1); g_free(tmp); tmp = tmp2; } @@ -3806,7 +3806,7 @@ gchar *tmp; /* If the message came from an ICQ user then escape any HTML */ - tmp = gaim_escape_html(msg2[0]); + tmp = g_markup_escape_text(msg2[0], -1); if (t) { /* This is an offline message */ /* The timestamp is UTC-ish, so we need to get the offset */ @@ -5611,7 +5611,7 @@ if (aim_sn_is_icq(gaim_account_get_username(account))) { /* from an ICQ user */ tmpmsg2 = gaim_strdup_withhtml(message); - tmpmsg = gaim_escape_html(tmpmsg2); + tmpmsg = g_markup_escape_text(tmpmsg2, -1); g_free(tmpmsg2); } else tmpmsg = gaim_strdup_withhtml(message); @@ -6795,7 +6795,7 @@ gchar *tmp1, *tmp2; tmp2 = gaim_markup_strip_html(away_utf8); g_free(away_utf8); - tmp1 = gaim_escape_html(tmp2); + tmp1 = g_markup_escape_text(tmp2, -1); g_free(tmp2); tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); g_free(tmp1);
--- a/src/protocols/silc/chat.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/silc/chat.c Sat Mar 26 02:43:49 2005 +0000 @@ -114,7 +114,7 @@ } s = g_string_new(""); - tmp2 = gaim_escape_html(channel->channel_name); + tmp2 = g_markup_escape_text(channel->channel_name, -1); g_string_append_printf(s, _("<b>Channel Name:</b> %s"), tmp2); g_free(tmp2); if (channel->user_list && silc_hash_table_count(channel->user_list)) @@ -124,7 +124,7 @@ silc_hash_table_list(channel->user_list, &htl); while (silc_hash_table_get(&htl, NULL, (void *)&chu)) { if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) { - tmp2 = gaim_escape_html(chu->client->nickname); + tmp2 = g_markup_escape_text(chu->client->nickname, -1); g_string_append_printf(s, _("<br><b>Channel Founder:</b> %s"), tmp2); g_free(tmp2); @@ -141,7 +141,7 @@ silc_hmac_get_name(channel->hmac)); if (channel->topic) { - tmp2 = gaim_escape_html(channel->topic); + tmp2 = g_markup_escape_text(channel->topic, -1); g_string_append_printf(s, _("<br><b>Channel Topic:</b><br>%s"), tmp2); g_free(tmp2); } @@ -1312,7 +1312,7 @@ flags, (unsigned char *)msg2, strlen(msg2), TRUE); if (ret) { - tmp = gaim_escape_html(msg); + tmp = g_markup_escape_text(msg, -1); serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, tmp, time(NULL)); g_free(tmp);
--- a/src/protocols/silc/ops.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/silc/ops.c Sat Mar 26 02:43:49 2005 +0000 @@ -90,7 +90,7 @@ if (!msg) return; - tmp = gaim_escape_html(msg); + tmp = g_markup_escape_text(msg, -1); /* Send to Gaim */ serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), sender->nickname ? @@ -117,7 +117,7 @@ } if (flags & SILC_MESSAGE_FLAG_UTF8) { - tmp = gaim_escape_html((const char *)message); + tmp = g_markup_escape_text((const char *)message, -1); /* Send to Gaim */ serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), sender->nickname ? @@ -169,7 +169,7 @@ if (!msg) return; - tmp = gaim_escape_html(msg); + tmp = g_markup_escape_text(msg, -1); /* Send to Gaim */ serv_got_im(gc, sender->nickname ? sender->nickname : "<unknown>", @@ -195,7 +195,7 @@ } if (flags & SILC_MESSAGE_FLAG_UTF8) { - tmp = gaim_escape_html((const char *)message); + tmp = g_markup_escape_text((const char *)message, -1); /* Send to Gaim */ serv_got_im(gc, sender->nickname ? sender->nickname : "<unknown>", @@ -331,7 +331,7 @@ if (!tmp) break; - esc = gaim_escape_html(tmp); + esc = g_markup_escape_text(tmp, -1); tmp2 = gaim_markup_linkify(esc); g_free(esc); @@ -961,16 +961,16 @@ user_modes = va_arg(vp, SilcBuffer); s = g_string_new(""); - tmp2 = gaim_escape_html(client_entry->nickname); + tmp2 = g_markup_escape_text(client_entry->nickname, -1); g_string_append_printf(s, "<b>%s:</b> %s", _("Nickname"), tmp2); g_free(tmp2); if (client_entry->realname) { - tmp2 = gaim_escape_html(client_entry->realname); + tmp2 = g_markup_escape_text(client_entry->realname, -1); g_string_append_printf(s, "<br><b>%s:</b> %s", _("Realname"), tmp2); g_free(tmp2); } if (client_entry->username) { - tmp2 = gaim_escape_html(client_entry->username); + tmp2 = g_markup_escape_text(client_entry->username, -1); if (client_entry->hostname) g_string_append_printf(s, "<br><b>%s:</b> %s@%s", _("Username"), tmp2, client_entry->hostname); else @@ -993,7 +993,7 @@ } if (statusstr) { - tmp2 = gaim_escape_html(statusstr); + tmp2 = g_markup_escape_text(statusstr, -1); g_string_append_printf(s, "<br><b>%s:</b> %s", _("Status Text"), tmp2); g_free(statusstr); g_free(tmp2); @@ -1053,7 +1053,7 @@ silc_free(m); } - tmp2 = gaim_escape_html(tmp); + tmp2 = g_markup_escape_text(tmp, -1); g_string_append_printf(s, "%s", tmp2); g_free(tmp2); silc_free(umodes); @@ -1112,16 +1112,16 @@ break; s = g_string_new(""); - tmp = gaim_escape_html(nickname); + tmp = g_markup_escape_text(nickname, -1); g_string_append_printf(s, "<b>%s:</b> %s", _("Nickname"), tmp); g_free(tmp); if (realname) { - tmp = gaim_escape_html(realname); + tmp = g_markup_escape_text(realname, -1); g_string_append_printf(s, "<br><b>%s:</b> %s", _("Realname"), tmp); g_free(tmp); } if (username) { - tmp = gaim_escape_html(username); + tmp = g_markup_escape_text(username, -1); if (client_entry && client_entry->hostname) g_string_append_printf(s, "<br><b>%s:</b> %s@%s", _("Username"), tmp, client_entry->hostname); else
--- a/src/protocols/silc/silc.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/silc/silc.c Sat Mar 26 02:43:49 2005 +0000 @@ -744,7 +744,7 @@ return; } - tmp = gaim_escape_html(sg->motd); + tmp = g_markup_escape_text(sg->motd, -1); gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL, tmp, NULL, NULL); g_free(tmp); @@ -1002,7 +1002,7 @@ if (!args || !args[0]) { topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(conv)); if (topic) { - tmp = gaim_escape_html(topic); + tmp = g_markup_escape_text(topic, -1); tmp2 = gaim_markup_linkify(tmp); buf = g_strdup_printf(_("current topic is: %s"), tmp2); g_free(tmp); @@ -1144,7 +1144,7 @@ return GAIM_CMD_RET_FAILED; } - tmp = gaim_escape_html(sg->motd); + tmp = g_markup_escape_text(sg->motd, -1); gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL, tmp, NULL, NULL); g_free(tmp);
--- a/src/protocols/yahoo/yahoo.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/yahoo/yahoo.c Sat Mar 26 02:43:49 2005 +0000 @@ -684,7 +684,7 @@ if (!msg || !g_utf8_validate(msg, -1, NULL)) return; - escmsg = gaim_escape_html(msg); + escmsg = g_markup_escape_text(msg, -1); prim = g_strdup_printf(_("Yahoo! system message for %s:"), me?me:gaim_connection_get_display_name(gc));
--- a/src/protocols/zephyr/zephyr.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/protocols/zephyr/zephyr.c Sat Mar 26 02:43:49 2005 +0000 @@ -757,7 +757,7 @@ buf = g_malloc(len + 1); g_snprintf(buf, len + 1, "%s", ptr); g_strchomp(buf); - tmpescape = gaim_escape_html(buf); + tmpescape = g_markup_escape_text(buf, -1); g_free(buf); buf2 = zephyr_to_html(tmpescape); buf3 = zephyr_recv_convert(gc,buf2, strlen(buf2));
--- a/src/util.c Sat Mar 26 01:20:31 2005 +0000 +++ b/src/util.c Sat Mar 26 02:43:49 2005 +0000 @@ -1673,39 +1673,6 @@ } char * -gaim_escape_html(const char *html) { - const char *c = html; - GString *ret; - - if (html == NULL) - return NULL; - - ret = g_string_new(""); - - while (*c) { - switch (*c) { - case '&': - ret = g_string_append(ret, "&"); - break; - case '<': - ret = g_string_append(ret, "<"); - break; - case '>': - ret = g_string_append(ret, ">"); - break; - case '"': - ret = g_string_append(ret, """); - break; - default: - ret = g_string_append_c(ret, *c); - } - c++; - } - - return g_string_free(ret, FALSE); -} - -char * gaim_unescape_html(const char *html) { char *unescaped = NULL;
--- a/src/util.h Sat Mar 26 01:20:31 2005 +0000 +++ b/src/util.h Sat Mar 26 02:43:49 2005 +0000 @@ -286,16 +286,6 @@ char *gaim_markup_linkify(const char *str); /** - * Escapes HTML special characters to be displayed literally. - * For example '&' is replaced by "&" and so on - * - * @param html The string in which to escape any HTML special characters - * - * @return the text with HTML special characters escaped - */ -char *gaim_escape_html(const char *html); - -/** * Unescapes HTML entities to their literal characters. * For example "&" is replaced by '&' and so on. * Actually only "&", """, "<" and ">" are currently