# HG changeset patch # User Nathan Walp # Date 1066370296 0 # Node ID 3a41c3f802289bcbaa4265bfa9c66aaf60cde5fb # Parent 0b961945c8aefa3f0f183c5e9e7a215f56dfbc66 [gaim-migrate @ 7868] more fun html entity stuff committer: Tailor Script diff -r 0b961945c8ae -r 3a41c3f80228 src/gtkimhtml.c --- a/src/gtkimhtml.c Thu Oct 16 22:22:18 2003 +0000 +++ b/src/gtkimhtml.c Fri Oct 17 05:58:16 2003 +0000 @@ -757,7 +757,7 @@ 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 @@ } 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)++; diff -r 0b961945c8ae -r 3a41c3f80228 src/util.c --- a/src/util.c Thu Oct 16 22:22:18 2003 +0000 +++ b/src/util.c Fri Oct 17 05:58:16 2003 +0000 @@ -790,6 +790,53 @@ 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);