comparison libpurple/protocols/msn/msn-utils.c @ 15787:a1564afbad84

Patch from plivesey, submitted in Adium Trac #5753 (http://trac.adiumx.com/ticket/5753), which fixes a memory stomper which occurred if the msn prpl were passed HTML with multiple style tags of the same type. This doesn't happen in pidgin, because the gtkhtml widget knows that msn can only have one all-or-none instance of each style, but libpurple should be able to handle being passed any sort of HTML. This therefore fixes an Adium crash.
author Evan Schoenberg <evan.s@dreskin.net>
date Mon, 12 Mar 2007 22:58:03 +0000
parents 5fe8042783c1
children 8cf610a18481
comparison
equal deleted inserted replaced
15783:f75aa2bf4973 15787:a1564afbad84
172 char *msg; 172 char *msg;
173 char *fontface = NULL; 173 char *fontface = NULL;
174 char fonteffect[4]; 174 char fonteffect[4];
175 char fontcolor[7]; 175 char fontcolor[7];
176 176
177 gboolean haveBold = FALSE;
178 gboolean haveItalic = FALSE;
179 gboolean haveUnderline = FALSE;
180 gboolean haveStrikethrough = FALSE;
181
177 g_return_if_fail(html != NULL); 182 g_return_if_fail(html != NULL);
178 g_return_if_fail(attributes != NULL); 183 g_return_if_fail(attributes != NULL);
179 g_return_if_fail(message != NULL); 184 g_return_if_fail(message != NULL);
180 185
181 len = strlen(html); 186 len = strlen(html);
195 msg[retcount++] = '\n'; 200 msg[retcount++] = '\n';
196 c += 4; 201 c += 4;
197 } 202 }
198 else if (!g_ascii_strncasecmp(c + 1, "i>", 2)) 203 else if (!g_ascii_strncasecmp(c + 1, "i>", 2))
199 { 204 {
200 strcat(fonteffect, "I"); 205 if ( haveItalic == FALSE )
206 {
207 strcat(fonteffect, "I");
208 haveItalic = TRUE;
209 }
201 c += 3; 210 c += 3;
202 } 211 }
203 else if (!g_ascii_strncasecmp(c + 1, "b>", 2)) 212 else if (!g_ascii_strncasecmp(c + 1, "b>", 2))
204 { 213 {
205 strcat(fonteffect, "B"); 214 if ( haveBold == FALSE )
215 {
216 strcat(fonteffect, "B");
217 haveBold = TRUE;
218 }
206 c += 3; 219 c += 3;
207 } 220 }
208 else if (!g_ascii_strncasecmp(c + 1, "u>", 2)) 221 else if (!g_ascii_strncasecmp(c + 1, "u>", 2))
209 { 222 {
210 strcat(fonteffect, "U"); 223 if ( haveUnderline == FALSE )
224 {
225 strcat(fonteffect, "U");
226 haveUnderline = TRUE;
227 }
211 c += 3; 228 c += 3;
212 } 229 }
213 else if (!g_ascii_strncasecmp(c + 1, "s>", 2)) 230 else if (!g_ascii_strncasecmp(c + 1, "s>", 2))
214 { 231 {
215 strcat(fonteffect, "S"); 232 if ( haveStrikethrough == FALSE )
233 {
234 strcat(fonteffect, "S");
235 haveStrikethrough = TRUE;
236 }
216 c += 3; 237 c += 3;
217 } 238 }
218 else if (!g_ascii_strncasecmp(c + 1, "a href=\"", 8)) 239 else if (!g_ascii_strncasecmp(c + 1, "a href=\"", 8))
219 { 240 {
220 c += 9; 241 c += 9;