# HG changeset patch # User Nathan Walp # Date 1050022322 0 # Node ID a20a644e0da49ff39c42a2a3dae49b6a22487008 # Parent bfcf72c5a9305723fb80fb11e6eba35be9a21ff3 [gaim-migrate @ 5467] getting better... gaim will ignore the tags for now, until we can really make use of them committer: Tailor Script diff -r bfcf72c5a930 -r a20a644e0da4 src/gtkimhtml.c --- a/src/gtkimhtml.c Thu Apr 10 22:53:57 2003 +0000 +++ b/src/gtkimhtml.c Fri Apr 11 00:52:02 2003 +0000 @@ -723,6 +723,9 @@ VALID_TAG ("STRONG"); VALID_TAG ("/STRONG"); + VALID_OPT_TAG ("SPAN"); + VALID_TAG ("/SPAN"); + if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { gchar *e = strstr (string + strlen("!--"), "-->"); if (e) { @@ -1188,8 +1191,10 @@ case 49: /* HTML (opt) */ case 50: /* CITE */ case 51: /* /CITE */ + case 56: /* SPAN */ + case 57: /* /SPAN */ break; - case 56: /* comment */ + case 58: /* comment */ NEW_BIT (NEW_TEXT_BIT); if (imhtml->show_comments) wpos = g_snprintf (ws, len, "%s", tag); diff -r bfcf72c5a930 -r a20a644e0da4 src/html.c --- a/src/html.c Thu Apr 10 22:53:57 2003 +0000 +++ b/src/html.c Fri Apr 11 00:52:02 2003 +0000 @@ -323,12 +323,21 @@ } } +struct gaim_parse_tag { + char *src_tag; + char *dest_tag; +}; + #define ALLOW_TAG_ALT(x, y) if(!g_ascii_strncasecmp(c, "<" x " ", strlen("<" x " "))) { \ char *o = strchr(c+1, '<'); \ char *p = strchr(c+1, '>'); \ if(p && (!o || p < o)) { \ - if(*(p-1) != '/') \ - tags = g_list_prepend(tags, y); \ + if(*(p-1) != '/') { \ + struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); \ + pt->src_tag = x; \ + pt->dest_tag = y; \ + tags = g_list_prepend(tags, pt); \ + } \ xhtml = g_string_append(xhtml, "<" y); \ c += strlen("<" x ); \ xhtml = g_string_append_len(xhtml, c, (p - c) + 1); \ @@ -343,8 +352,12 @@ !g_ascii_strncasecmp(c+strlen("<" x), "/>", 2))) { \ xhtml = g_string_append(xhtml, "<" y); \ c += strlen("<" x); \ - if(*c != '/') \ - tags = g_list_prepend(tags, y); \ + if(*c != '/') { \ + struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); \ + pt->src_tag = x; \ + pt->dest_tag = y; \ + tags = g_list_prepend(tags, pt); \ + } \ continue; \ } #define ALLOW_TAG(x) ALLOW_TAG_ALT(x, x) @@ -372,19 +385,23 @@ if(*(c+1) == '/') { /* closing tag */ tag = tags; while(tag) { - if(!g_ascii_strncasecmp((c+2), tag->data, strlen(tag->data)) && *(c+strlen(tag->data)+2) == '>') { - c += strlen(tag->data) + 3; + struct gaim_parse_tag *pt = tag->data; + if(!g_ascii_strncasecmp((c+2), pt->src_tag, strlen(pt->src_tag)) && *(c+strlen(pt->src_tag)+2) == '>') { + c += strlen(pt->src_tag) + 3; break; } tag = tag->next; } if(tag) { while(tags) { - g_string_append_printf(xhtml, "", (char *)tags->data); + struct gaim_parse_tag *pt = tags->data; + g_string_append_printf(xhtml, "", pt->dest_tag); if(tags == tag) break; - tags = g_list_remove(tags, tags->data); + tags = g_list_remove(tags, pt); + g_free(pt); } + g_free(tag->data); tags = g_list_remove(tags, tag->data); } else { /* we tried to close a tag we never opened! escape it @@ -418,16 +435,46 @@ ALLOW_TAG("p"); ALLOW_TAG("pre"); ALLOW_TAG("q"); - ALLOW_TAG_ALT("s", "strike"); /* FIXME: see strike */ ALLOW_TAG("span"); - ALLOW_TAG("strike"); /* FIXME: not valid, need to convert */ ALLOW_TAG("strong"); - ALLOW_TAG("sub"); /* FIXME: not valid, need to convert */ - ALLOW_TAG("sup"); /* FIXME: not valid, need to convert */ - ALLOW_TAG("u"); /* FIXME: need to convert */ - ALLOW_TAG_ALT("underline","u"); /* FIXME: need to convert */ ALLOW_TAG("ul"); + if(!g_ascii_strncasecmp(c, "", 2) || !g_ascii_strncasecmp(c, "", strlen(""))) { + struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); + pt->src_tag = *(c+2) == '>' ? "u" : "underline"; + pt->dest_tag = "span"; + tags = g_list_prepend(tags, pt); + c = strchr(c, '>') + 1; + xhtml = g_string_append(xhtml, ""); + continue; + } + if(!g_ascii_strncasecmp(c, "", 2) || !g_ascii_strncasecmp(c, "", strlen(""))) { + struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); + pt->src_tag = *(c+2) == '>' ? "s" : "strike"; + pt->dest_tag = "span"; + tags = g_list_prepend(tags, pt); + c = strchr(c, '>') + 1; + xhtml = g_string_append(xhtml, ""); + continue; + } + if(!g_ascii_strncasecmp(c, "", 5)) { + struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); + pt->src_tag = "sub"; + pt->dest_tag = "span"; + tags = g_list_prepend(tags, pt); + c = strchr(c, '>') + 1; + xhtml = g_string_append(xhtml, ""); + continue; + } + if(!g_ascii_strncasecmp(c, "", 5)) { + struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); + pt->src_tag = "sup"; + pt->dest_tag = "span"; + tags = g_list_prepend(tags, pt); + c = strchr(c, '>') + 1; + xhtml = g_string_append(xhtml, ""); + continue; + } if(!g_ascii_strncasecmp(c, ""); if(p) {