comparison src/ft.c @ 10774:d83f745c997b

[gaim-migrate @ 12383] 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. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 02 Apr 2005 17:18:43 +0000
parents f2e86683cafc
children 9695281b1aa1
comparison
equal deleted inserted replaced
10773:888d4c328be5 10774:d83f745c997b
115 115
116 static void 116 static void
117 gaim_xfer_conversation_write(GaimXfer *xfer, char *message, gboolean is_error) 117 gaim_xfer_conversation_write(GaimXfer *xfer, char *message, gboolean is_error)
118 { 118 {
119 GaimConversation *conv = NULL; 119 GaimConversation *conv = NULL;
120 GString *gs_message = NULL;
121 GaimMessageFlags flags = GAIM_MESSAGE_SYSTEM; 120 GaimMessageFlags flags = GAIM_MESSAGE_SYSTEM;
121 char *escaped;
122 122
123 g_return_if_fail(xfer != NULL); 123 g_return_if_fail(xfer != NULL);
124 g_return_if_fail(message != NULL); 124 g_return_if_fail(message != NULL);
125 125
126 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, xfer->who, 126 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, xfer->who,
127 gaim_xfer_get_account(xfer)); 127 gaim_xfer_get_account(xfer));
128 128
129 if (conv == NULL) 129 if (conv == NULL)
130 return; 130 return;
131 131
132 gs_message = g_string_new(message); 132 escaped = g_markup_escape_text(message, -1);
133 133
134 if (is_error) 134 if (is_error)
135 flags = GAIM_MESSAGE_ERROR; 135 flags = GAIM_MESSAGE_ERROR;
136 136
137 gaim_conversation_write(conv, NULL, gs_message->str, flags, time(NULL)); 137 gaim_conversation_write(conv, NULL, escaped, flags, time(NULL));
138 g_string_free(gs_message, TRUE); 138 g_free(escaped);
139 } 139 }
140 140
141 static void gaim_xfer_show_file_error(GaimXfer *xfer, const char *filename) 141 static void gaim_xfer_show_file_error(GaimXfer *xfer, const char *filename)
142 { 142 {
143 gchar *msg = NULL; 143 gchar *msg = NULL;
246 } 246 }
247 247
248 static void 248 static void
249 gaim_xfer_ask_recv(GaimXfer *xfer) 249 gaim_xfer_ask_recv(GaimXfer *xfer)
250 { 250 {
251 char *buf, *size_buf, *escaped; 251 char *buf, *size_buf;
252 size_t size; 252 size_t size;
253 253
254 /* If we have already accepted the request, ask the destination file 254 /* If we have already accepted the request, ask the destination file
255 name directly */ 255 name directly */
256 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) { 256 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) {
258 258
259 if (gaim_xfer_get_filename(xfer) != NULL) 259 if (gaim_xfer_get_filename(xfer) != NULL)
260 { 260 {
261 size = gaim_xfer_get_size(xfer); 261 size = gaim_xfer_get_size(xfer);
262 size_buf = gaim_str_size_to_units(size); 262 size_buf = gaim_str_size_to_units(size);
263 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
264 buf = g_strdup_printf(_("%s wants to send you %s (%s)"), 263 buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
265 buddy ? gaim_buddy_get_alias(buddy) : xfer->who, 264 buddy ? gaim_buddy_get_alias(buddy) : xfer->who,
266 escaped, size_buf); 265 gaim_xfer_get_filename(xfer), size_buf);
267 g_free(size_buf); 266 g_free(size_buf);
268 g_free(escaped);
269 } 267 }
270 else 268 else
271 { 269 {
272 buf = g_strdup_printf(_("%s wants to send you a file"), 270 buf = g_strdup_printf(_("%s wants to send you a file"),
273 buddy ? gaim_buddy_get_alias(buddy) : xfer->who); 271 buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
929 927
930 void 928 void
931 gaim_xfer_cancel_local(GaimXfer *xfer) 929 gaim_xfer_cancel_local(GaimXfer *xfer)
932 { 930 {
933 GaimXferUiOps *ui_ops; 931 GaimXferUiOps *ui_ops;
934 char *msg = NULL, *escaped; 932 char *msg = NULL;
935 933
936 g_return_if_fail(xfer != NULL); 934 g_return_if_fail(xfer != NULL);
937 935
938 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL); 936 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL);
939 937
940 if (gaim_xfer_get_filename(xfer) != NULL) 938 if (gaim_xfer_get_filename(xfer) != NULL)
941 { 939 {
942 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
943 msg = g_strdup_printf(_("You canceled the transfer of %s"), 940 msg = g_strdup_printf(_("You canceled the transfer of %s"),
944 escaped); 941 gaim_xfer_get_filename(xfer));
945 g_free(escaped);
946 } 942 }
947 else 943 else
948 { 944 {
949 msg = g_strdup_printf(_("File transfer cancelled")); 945 msg = g_strdup_printf(_("File transfer cancelled"));
950 } 946 }
987 983
988 void 984 void
989 gaim_xfer_cancel_remote(GaimXfer *xfer) 985 gaim_xfer_cancel_remote(GaimXfer *xfer)
990 { 986 {
991 GaimXferUiOps *ui_ops; 987 GaimXferUiOps *ui_ops;
992 gchar *msg, *escaped; 988 gchar *msg;
993 GaimAccount *account; 989 GaimAccount *account;
994 GaimBuddy *buddy; 990 GaimBuddy *buddy;
995 991
996 g_return_if_fail(xfer != NULL); 992 g_return_if_fail(xfer != NULL);
997 993
1001 account = gaim_xfer_get_account(xfer); 997 account = gaim_xfer_get_account(xfer);
1002 buddy = gaim_find_buddy(account, xfer->who); 998 buddy = gaim_find_buddy(account, xfer->who);
1003 999
1004 if (gaim_xfer_get_filename(xfer) != NULL) 1000 if (gaim_xfer_get_filename(xfer) != NULL)
1005 { 1001 {
1006 escaped = g_markup_escape_text(gaim_xfer_get_filename(xfer), -1);
1007 msg = g_strdup_printf(_("%s canceled the transfer of %s"), 1002 msg = g_strdup_printf(_("%s canceled the transfer of %s"),
1008 buddy ? gaim_buddy_get_alias(buddy) : xfer->who, escaped); 1003 buddy ? gaim_buddy_get_alias(buddy) : xfer->who, gaim_xfer_get_filename(xfer));
1009 g_free(escaped);
1010 } 1004 }
1011 else 1005 else
1012 { 1006 {
1013 msg = g_strdup_printf(_("%s canceled the file transfer"), 1007 msg = g_strdup_printf(_("%s canceled the file transfer"),
1014 buddy ? gaim_buddy_get_alias(buddy) : xfer->who); 1008 buddy ? gaim_buddy_get_alias(buddy) : xfer->who);