Update of /cvsroot/gaim/gaim/src
In directory sc8-pr-cvs1:/tmp/cvs-serv29178/src
Modified Files:
gtkimhtml.c
Log Message:
fix © and ® in gtkimhtml
fix a potential segfault on jabber
Index: gtkimhtml.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/gtkimhtml.c,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -p -r1.200 -r1.201
--- gtkimhtml.c 4 Oct 2003 19:34:53 -0000 1.200
+++ gtkimhtml.c 16 Oct 2003 04:17:25 -0000 1.201
@@ -754,43 +754,45 @@ gtk_smiley_tree_image (GtkIMHtml *im
static gboolean
gtk_imhtml_is_amp_escape (const gchar *string,
- gchar *replace,
+ gchar **replace,
gint *length)
{
+ static char buf[3];
g_return_val_if_fail (string != NULL, FALSE);
g_return_val_if_fail (replace != NULL, FALSE);
g_return_val_if_fail (length != NULL, FALSE);
if (!g_ascii_strncasecmp (string, "&", 5)) {
- *replace = '&';
+ *replace = "&";
*length = 5;
} else if (!g_ascii_strncasecmp (string, "<", 4)) {
- *replace = '<';
+ *replace = "<";
*length = 4;
} else if (!g_ascii_strncasecmp (string, ">", 4)) {
- *replace = '>';
+ *replace = ">";
*length = 4;
} else if (!g_ascii_strncasecmp (string, " ", 6)) {
- *replace = ' ';
+ *replace = " ";
*length = 6;
} else if (!g_ascii_strncasecmp (string, "©", 6)) {
- *replace = '©'; /* was: '©' */
+ *replace = "©";
*length = 6;
} else if (!g_ascii_strncasecmp (string, """, 6)) {
- *replace = '\"';
+ *replace = "\"";
*length = 6;
} else if (!g_ascii_strncasecmp (string, "®", 5)) {
- *replace = '®'; /* was: '®' */
+ *replace = "®";
*length = 5;
} else if (!g_ascii_strncasecmp (string, "'", 6)) {
- *replace = '\'';
+ *replace = "\'";
*length = 6;
} else if (*(string + 1) == '#') {
guint pound = 0;
if ((sscanf (string, "&#%u;", £) == 1) && pound != 0) {
if (*(string + 3 + (gint)log10 (pound)) != ';')
return FALSE;
- *replace = (gchar)pound;
+ g_snprintf(buf, sizeof(buf), "%c", (gchar)pound);
+ *replace = buf;
*length = 2;
while (isdigit ((gint) string [*length])) (*length)++;
if (string [*length] == ';') (*length)++;
@@ -898,7 +900,7 @@ gtk_imhtml_get_html_opt (gchar *ta
gchar *e, *a;
gchar *val;
gint len;
- gchar c;
+ gchar *c;
GString *ret;
while (g_ascii_strncasecmp (t, opt, strlen (opt))) {
@@ -935,7 +937,7 @@ gtk_imhtml_get_html_opt (gchar *ta
e = val;
while(*e) {
if(gtk_imhtml_is_amp_escape(e, &c, &len)) {
- ret = g_string_append_c(ret, c);
+ ret = g_string_append(ret, c);
e += len;
} else {
ret = g_string_append_c(ret, *e);
@@ -1037,7 +1039,7 @@ GString* gtk_imhtml_append_text_with_ima
gint tlen, smilelen, wpos=0;
gint type;
const gchar *c;
- gchar amp;
+ gchar *amp;
guint bold = 0,
italics = 0,
@@ -1347,7 +1349,9 @@ GString* gtk_imhtml_append_text_with_ima
if(tag)
g_free(tag); /* This was allocated back in VALID_TAG() */
} else if (*c == '&' && gtk_imhtml_is_amp_escape (c, &, &tlen)) {
- ws [wpos++] = amp;
+ while(*amp) {
+ ws [wpos++] = *amp++;
+ }
c += tlen;
pos += tlen;
} else if (*c == '\n') {
|