Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15838/src Modified Files: account.c blist.c blist.h ft.c gtkdialogs.c gtknotify.c gtkpounce.c gtkrequest.c server.c Log Message: Some escaping stuff, all over the place. Various escaping fixes in the IRC prpl. The core and plugins only need to escape text if it's going to be shown in a gtkimhtml or equivalent - such as writing to a conversation window, or gaim_notify_{formatted,userinfo} The primary and secondary text for all notify and request API functions do NOT need to be escaped by the core or plugins, because whether html-like markup is required for these is UI dependent. Now we always escape these in the Gtk UI request & notify ops. Should I backport any of the above to oldstatus? I also removed gaim_chat_get_display_name() - it was almost a duplicate of gaim_chat_get_name(), and it leaked. Index: account.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/account.c,v retrieving revision 1.136 retrieving revision 1.137 diff -u -d -p -r1.136 -r1.137 --- account.c 28 Mar 2005 04:26:33 -0000 1.136 +++ account.c 2 Apr 2005 17:18:37 -0000 1.137 @@ -775,22 +775,19 @@ static void request_password(GaimAccount *account) { gchar *primary; - gchar *escaped; const gchar *username; /* Close any previous password request windows */ gaim_request_close_with_handle(account); username = gaim_account_get_username(account); - escaped = g_markup_escape_text(username, strlen(username)); - primary = g_strdup_printf(_("Enter password for %s (%s)"), escaped, + primary = g_strdup_printf(_("Enter password for %s (%s)"), username, gaim_account_get_protocol_name(account)); gaim_request_input(account, _("Enter Password"), primary, NULL, NULL, FALSE, TRUE, NULL, _("OK"), G_CALLBACK(request_password_ok_cb), _("Cancel"), NULL, account); g_free(primary); - g_free(escaped); } void Index: blist.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/blist.c,v retrieving revision 1.205 retrieving revision 1.206 diff -u -d -p -r1.205 -r1.206 --- blist.c 25 Mar 2005 21:56:29 -0000 1.205 +++ blist.c 2 Apr 2005 17:18:38 -0000 1.206 @@ -1019,34 +1019,6 @@ GaimChat *gaim_chat_new(GaimAccount *acc return chat; } -char *gaim_chat_get_display_name(GaimChat *chat) -{ - char *name; - - g_return_val_if_fail(chat != NULL, FALSE); - - if (chat->alias != NULL) { - name = g_strdup(chat->alias); - } else { - GList *parts; - GaimPlugin *prpl; - GaimPluginProtocolInfo *prpl_info; - struct proto_chat_entry *pce; - - prpl = gaim_find_prpl(gaim_account_get_protocol_id(chat->account)); - prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); - - parts = prpl_info->chat_info(chat->account->gc); - - pce = parts->data; - name = g_markup_escape_text(g_hash_table_lookup(chat->components, - pce->identifier), -1); - g_list_free(parts); - } - - return name; -} - GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias) { GaimBlistUiOps *ops = gaimbuddylist->ui_ops; Index: blist.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/blist.h,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -p -r1.83 -r1.84 --- blist.h 20 Mar 2005 01:42:53 -0000 1.83 +++ blist.h 2 Apr 2005 17:18:39 -0000 1.84 @@ -318,14 +318,6 @@ void gaim_blist_rename_group(GaimGroup * GaimChat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components); /** - * Gets the alias of the chat, or the chat name if the alias does not exist - * - * @param chat The chat - * @return The display name of the chat - */ -char *gaim_chat_get_display_name(GaimChat *chat); - -/** * Adds a new chat to the buddy list. * * The chat will be inserted right after node or appended to the end Index: ft.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/ft.c,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -p -r1.83 -r1.84 --- ft.c 6 Mar 2005 00:23:50 -0000 1.83 +++ ft.c 2 Apr 2005 17:18:39 -0000 1.84 @@ -117,8 +117,8 @@ static void gaim_xfer_conversation_write(GaimXfer *xfer, char *message, gboolean is_error) { GaimConversation *conv = NULL; - GString *gs_message = NULL; GaimMessageFlags flags = GAIM_MESSAGE_SYSTEM; + char *escaped; g_return_if_fail(xfer != NULL); g_return_if_fail(message != NULL); @@ -129,13 +129,13 @@ gaim_xfer_conversation_write(GaimXfer *x if (conv == NULL) return; - gs_message = g_string_new(message); + escaped = g_markup_escape_text(message, -1); if (is_error) flags = GAIM_MESSAGE_ERROR; - gaim_conversation_write(conv, NULL, gs_message->str, flags, time(NULL)); - g_string_free(gs_message, TRUE); + gaim_conversation_write(conv, NULL, escaped, flags, time(NULL)); + g_free(escaped); } static void gaim_xfer_show_file_error(GaimXfer *xfer, const char *filename) @@ -248,7 +248,7 @@ cancel_recv_cb(GaimXfer *xfer) static void gaim_xfer_ask_recv(GaimXfer *xfer) { - char *buf, *size_buf, *escaped; + char *buf, *size_buf; size_t size; /* If we have already accepted the request, ask the destination file @@ -260,12 +260,10 @@ gaim_xfer_ask_recv(GaimXfer *xfer) { size = gaim_xfer_get_size(xfer); size_buf = gaim_str_size_to_units(size); - escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); buf = g_strdup_printf(_("%s wants to send you %s (%s)"), buddy ? gaim_buddy_get_alias(buddy) : xfer->who, - escaped, size_buf); + gaim_xfer_get_filename(xfer), size_buf); g_free(size_buf); - g_free(escaped); } else { @@ -931,7 +929,7 @@ void gaim_xfer_cancel_local(GaimXfer *xfer) { GaimXferUiOps *ui_ops; - char *msg = NULL, *escaped; + char *msg = NULL; g_return_if_fail(xfer != NULL); @@ -939,10 +937,8 @@ gaim_xfer_cancel_local(GaimXfer *xfer) if (gaim_xfer_get_filename(xfer) != NULL) { - escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); msg = g_strdup_printf(_("You canceled the transfer of %s"), - escaped); - g_free(escaped); + gaim_xfer_get_filename(xfer)); } else { @@ -989,7 +985,7 @@ void gaim_xfer_cancel_remote(GaimXfer *xfer) { GaimXferUiOps *ui_ops; - gchar *msg, *escaped; + gchar *msg; GaimAccount *account; GaimBuddy *buddy; @@ -1003,10 +999,8 @@ gaim_xfer_cancel_remote(GaimXfer *xfer) if (gaim_xfer_get_filename(xfer) != NULL) { - escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1); msg = g_strdup_printf(_("%s canceled the transfer of %s"), - buddy ? gaim_buddy_get_alias(buddy) : xfer->who, escaped); - g_free(escaped); + buddy ? gaim_buddy_get_alias(buddy) : xfer->who, gaim_xfer_get_filename(xfer)); } else { Index: gtkdialogs.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkdialogs.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -p -r1.40 -r1.41 --- gtkdialogs.c 9 Mar 2005 00:30:35 -0000 1.40 +++ gtkdialogs.c 2 Apr 2005 17:18:40 -0000 1.41 @@ -986,7 +986,7 @@ gaim_gtkdialogs_remove_chat_cb(GaimChat void gaim_gtkdialogs_remove_chat(GaimChat *chat) { - gchar *name = gaim_chat_get_display_name(chat); + const gchar *name = gaim_chat_get_name(chat); gchar *text = g_strdup_printf(_("You are about to remove the chat %s from your buddy list. Do you want to continue?"), name); g_return_if_fail(chat != NULL); @@ -995,6 +995,5 @@ gaim_gtkdialogs_remove_chat(GaimChat *ch _("Remove Chat"), G_CALLBACK(gaim_gtkdialogs_remove_chat_cb), _("Cancel"), NULL); - g_free(name); g_free(text); } Index: gtknotify.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtknotify.c,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -p -r1.78 -r1.79 --- gtknotify.c 27 Mar 2005 17:39:22 -0000 1.78 +++ gtknotify.c 2 Apr 2005 17:18:40 -0000 1.79 @@ -128,6 +128,7 @@ gaim_gtk_notify_message(GaimNotifyMsgTyp GtkWidget *img = NULL; char label_text[2048]; const char *icon_name = NULL; + char *primary_esc, *secondary_esc; switch (type) { @@ -175,9 +176,13 @@ gaim_gtk_notify_message(GaimNotifyMsgTyp if (img != NULL) gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); + primary_esc = g_markup_escape_text(primary, -1); + secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; g_snprintf(label_text, sizeof(label_text), "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", - primary, (secondary ? secondary : "")); + primary_esc, (secondary ? secondary_esc : "")); + g_free(primary_esc); + g_free(secondary_esc); label = gtk_label_new(NULL); @@ -350,7 +355,7 @@ gaim_gtk_notify_formatted(const char *ti GtkWidget *frame; int options = 0; char label_text[2048]; - char *linked_text; + char *linked_text, *primary_esc, *secondary_esc; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), title); @@ -366,11 +371,15 @@ gaim_gtk_notify_formatted(const char *ti gtk_widget_show(vbox); /* Setup the descriptive label */ + primary_esc = g_markup_escape_text(primary, -1); + secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; g_snprintf(label_text, sizeof(label_text), "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", - primary, + primary_esc, (secondary ? "\n" : ""), - (secondary ? secondary : "")); + (secondary ? secondary_esc : "")); + g_free(primary_esc); + g_free(secondary_esc); label = gtk_label_new(NULL); @@ -438,6 +447,7 @@ gaim_gtk_notify_searchresults(GaimConnec GtkTreeIter iter; int i; char *label_text; + char *primary_esc, *secondary_esc; data = g_malloc(sizeof(GaimNotifySearchResultsData)); @@ -456,11 +466,15 @@ gaim_gtk_notify_searchresults(GaimConnec gtk_widget_show(vbox); /* Setup the descriptive label */ + primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; + secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; label_text = g_strdup_printf( "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", - (primary ? primary : ""), + (primary ? primary_esc : ""), (primary && secondary ? "\n" : ""), - (secondary ? secondary : "")); + (secondary ? secondary_esc : "")); + g_free(primary_esc); + g_free(secondary_esc); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), label_text); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); @@ -528,11 +542,13 @@ gaim_gtk_notify_searchresults(GaimConnec for (i = 0; results[i] != NULL; i++) { + char *escaped = g_markup_escape_text(results[i], -1); gtk_list_store_append(model, &iter); gtk_list_store_set(model, &iter, COLUMN_ICON, scaled, - COLUMN_SCREENNAME, results[i], + COLUMN_SCREENNAME, escaped, -1); + g_free(escaped); } data->account = gc->account; Index: gtkpounce.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkpounce.c,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -p -r1.70 -r1.71 --- gtkpounce.c 11 Feb 2005 06:10:12 -0000 1.70 +++ gtkpounce.c 2 Apr 2005 17:18:40 -0000 1.71 @@ -954,9 +954,6 @@ pounce_cb(GaimPounce *pounce, GaimPounce { char tmp[1024]; const char *name_shown; - char *escaped; - - escaped = g_markup_escape_text(alias, -1); /* * Here we place the protocol name in the pounce dialog to lessen @@ -980,9 +977,7 @@ pounce_cb(GaimPounce *pounce, GaimPounce (events & GAIM_POUNCE_AWAY) ? _("%s has gone away. (%s)") : _("Unknown pounce event. Please report this!"), - escaped, gaim_account_get_protocol_name(account)); - - g_free(escaped); + alias, gaim_account_get_protocol_name(account)); /* * Ok here is where I change the second argument, title, from Index: gtkrequest.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkrequest.c,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -p -r1.95 -r1.96 --- gtkrequest.c 8 Mar 2005 03:15:33 -0000 1.95 +++ gtkrequest.c 2 Apr 2005 17:18:40 -0000 1.96 @@ -286,6 +286,7 @@ gaim_gtk_request_input(const char *title GtkWidget *img; GtkWidget *toolbar; char *label_text; + char *primary_esc, *secondary_esc; data = g_new0(GaimGtkRequestData, 1); data->type = GAIM_REQUEST_INPUT; @@ -332,11 +333,15 @@ gaim_gtk_request_input(const char *title gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); /* Descriptive label */ + primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; + secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" "%s</span>%s%s" : "%s%s%s"), - (primary ? primary : ""), + (primary ? primary_esc : ""), ((primary && secondary) ? "\n\n" : ""), - (secondary ? secondary : "")); + (secondary ? secondary_esc : "")); + g_free(primary_esc); + g_free(secondary_esc); label = gtk_label_new(NULL); @@ -435,6 +440,7 @@ gaim_gtk_request_choice(const char *titl GtkWidget *radio = NULL; char *label_text; char *radio_text; + char *primary_esc, *secondary_esc; data = g_new0(GaimGtkRequestData, 1); data->type = GAIM_REQUEST_ACTION; @@ -483,11 +489,15 @@ gaim_gtk_request_choice(const char *titl gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); /* Descriptive label */ + primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; + secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" "%s</span>%s%s" : "%s%s%s"), - (primary ? primary : ""), + (primary ? primary_esc : ""), ((primary && secondary) ? "\n\n" : ""), - (secondary ? secondary : "")); + (secondary ? secondary_esc : "")); + g_free(primary_esc); + g_free(secondary_esc); label = gtk_label_new(NULL); @@ -530,6 +540,7 @@ gaim_gtk_request_action(const char *titl GtkWidget *img; void **buttons; char *label_text; + char *primary_esc, *secondary_esc; int i; data = g_new0(GaimGtkRequestData, 1); @@ -587,11 +598,15 @@ gaim_gtk_request_action(const char *titl gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); /* Descriptive label */ + primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; + secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" "%s</span>%s%s" : "%s%s%s"), - (primary ? primary : ""), + (primary ? primary_esc : ""), ((primary && secondary) ? "\n\n" : ""), - (secondary ? secondary : "")); + (secondary ? secondary_esc : "")); + g_free(primary_esc); + g_free(secondary_esc); label = gtk_label_new(NULL); @@ -1234,6 +1249,7 @@ gaim_gtk_request_fields(const char *titl GaimRequestFieldGroup *group; GaimRequestField *field; char *label_text; + char *primary_esc, *secondary_esc; int total_fields = 0; data = g_new0(GaimGtkRequestData, 1); @@ -1281,8 +1297,10 @@ gaim_gtk_request_fields(const char *titl sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); if(primary) { + primary_esc = g_markup_escape_text(primary, -1); label_text = g_strdup_printf( - "<span weight=\"bold\" size=\"larger\">%s</span>", primary); + "<span weight=\"bold\" size=\"larger\">%s</span>", primary_esc); + g_free(primary_esc); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), label_text); @@ -1315,9 +1333,11 @@ gaim_gtk_request_fields(const char *titl } if (secondary) { + secondary_esc = g_markup_escape_text(secondary, -1); label = gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(label), secondary); + gtk_label_set_markup(GTK_LABEL(label), secondary_esc); + g_free(secondary_esc); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0); Index: server.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/server.c,v retrieving revision 1.456 retrieving revision 1.457 diff -u -d -p -r1.456 -r1.457 --- server.c 27 Mar 2005 17:50:26 -0000 1.456 +++ server.c 2 Apr 2005 17:18:41 -0000 1.457 @@ -1050,8 +1050,6 @@ void serv_got_chat_invite(GaimConnection GaimAccount *account; char buf2[BUF_LONG]; struct chat_invite_data *cid = g_new0(struct chat_invite_data, 1); - char *name_escaped = g_markup_escape_text(name, -1); - char *who_escaped = g_markup_escape_text(who, -1); account = gaim_connection_get_account(gc); @@ -1060,19 +1058,14 @@ void serv_got_chat_invite(GaimConnection if (message != NULL) { - char *message_escaped = g_markup_escape_text(message, -1); g_snprintf(buf2, sizeof(buf2), - _("%s has invited %s to the chat room %s:\n<b>%s</b>"), - who_escaped, gaim_account_get_username(account), name_escaped, message_escaped); - g_free(message_escaped); + _("%s has invited %s to the chat room %s:\n%s"), + who, gaim_account_get_username(account), name, message); } else g_snprintf(buf2, sizeof(buf2), _("%s has invited %s to the chat room %s\n"), - who_escaped, gaim_account_get_username(account), name_escaped); - - g_free(name_escaped); - g_free(who_escaped); + who, gaim_account_get_username(account), name); cid->gc = gc; cid->components = data; |