From: Nathan W. <fac...@us...> - 2003-10-17 06:04:56
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1:/tmp/cvs-serv23712/src Modified Files: gtkimhtml.c util.c Log Message: more fun html entity stuff Index: gtkimhtml.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkimhtml.c,v retrieving revision 1.202 retrieving revision 1.203 diff -u -d -p -r1.202 -r1.203 --- gtkimhtml.c 16 Oct 2003 04:35:41 -0000 1.202 +++ gtkimhtml.c 17 Oct 2003 05:58:16 -0000 1.203 @@ -757,7 +757,7 @@ gtk_imhtml_is_amp_escape (const gchar *s gchar **replace, gint *length) { - static char buf[6]; + static char buf[7]; g_return_val_if_fail (string != NULL, FALSE); g_return_val_if_fail (replace != NULL, FALSE); g_return_val_if_fail (length != NULL, FALSE); @@ -789,9 +789,11 @@ gtk_imhtml_is_amp_escape (const gchar *s } else if (*(string + 1) == '#') { guint pound = 0; if ((sscanf (string, "&#%u;", £) == 1) && pound != 0) { + int buflen; if (*(string + 3 + (gint)log10 (pound)) != ';') return FALSE; - g_unichar_to_utf8((gunichar)pound, buf); + buflen = g_unichar_to_utf8((gunichar)pound, buf); + buf[buflen] = '\0'; *replace = buf; *length = 2; while (isdigit ((gint) string [*length])) (*length)++; Index: util.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/util.c,v retrieving revision 1.229 retrieving revision 1.230 diff -u -d -p -r1.229 -r1.230 --- util.c 14 Oct 2003 21:17:20 -0000 1.229 +++ util.c 17 Oct 2003 05:58:16 -0000 1.230 @@ -790,6 +790,53 @@ gaim_markup_html_to_xhtml(const char *ht plain = g_string_append_c(plain, '<'); c++; } + } else if(*c == '&') { + char buf[7]; + char *pln; + int len = 1; + guint pound; + if(!g_ascii_strncasecmp(c, "&", 5)) { + pln = "&"; + len = 5; + } else if(!g_ascii_strncasecmp(c, "<", 4)) { + pln = "<"; + len = 4; + } else if(!g_ascii_strncasecmp(c, ">", 4)) { + pln = ">"; + len = 4; + } else if(!g_ascii_strncasecmp(c, " ", 6)) { + pln = " "; + len = 6; + } else if(!g_ascii_strncasecmp(c, "©", 6)) { + pln = "©"; + len = 6; + } else if(!g_ascii_strncasecmp(c, """, 6)) { + pln = "\""; + len = 6; + } else if(!g_ascii_strncasecmp(c, "®", 5)) { + pln = "®"; + len = 5; + } else if(!g_ascii_strncasecmp(c, "'", 6)) { + pln = "\'"; + len = 6; + } else if(*(c+1) == '#' && (sscanf(c, "&#%u;", £) == 1) && + pound != 0 && *(c+3+(gint)log10(pound)) == ';') { + int buflen = g_unichar_to_utf8((gunichar)pound, buf); + buf[buflen] = '\0'; + pln = buf; + + + len = 2; + while(isdigit((gint) c [len])) len++; + if(c [len] == ';') len++; + } else { + len = 1; + g_snprintf(buf, sizeof(buf), "%c", *c); + pln = buf; + } + xhtml = g_string_append_len(xhtml, c, len); + plain = g_string_append(plain, pln); + c += len; } else { xhtml = g_string_append_c(xhtml, *c); plain = g_string_append_c(plain, *c); |