From: Nathan W. <fac...@us...> - 2003-04-19 06:28:43
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1:/tmp/cvs-serv9865/src Modified Files: gtkimhtml.c html.c Log Message: made jabber xhtml stuff even better, and fixed a couple bugs in the process Index: gtkimhtml.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkimhtml.c,v retrieving revision 1.178 retrieving revision 1.179 diff -u -d -r1.178 -r1.179 --- gtkimhtml.c 13 Apr 2003 14:04:45 -0000 1.178 +++ gtkimhtml.c 19 Apr 2003 06:28:39 -0000 1.179 @@ -730,6 +730,7 @@ VALID_OPT_TAG ("SPAN"); VALID_TAG ("/SPAN"); + VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */ if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { gchar *e = strstr (string + strlen("!--"), "-->"); @@ -1006,6 +1007,7 @@ } break; case 25: /* BR */ + case 58: /* BR/ */ ws[wpos] = '\n'; wpos++; NEW_BIT (NEW_TEXT_BIT); @@ -1199,7 +1201,7 @@ case 56: /* SPAN */ case 57: /* /SPAN */ break; - case 58: /* comment */ + case 59: /* comment */ NEW_BIT (NEW_TEXT_BIT); if (imhtml->show_comments) wpos = g_snprintf (ws, len, "%s", tag); Index: html.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/html.c,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- html.c 16 Apr 2003 17:33:25 -0000 1.42 +++ html.c 19 Apr 2003 06:28:40 -0000 1.43 @@ -424,7 +424,6 @@ ALLOW_TAG_ALT("b", "strong"); ALLOW_TAG("blockquote"); ALLOW_TAG_ALT("bold", "strong"); - ALLOW_TAG("br"); ALLOW_TAG("cite"); ALLOW_TAG("div"); ALLOW_TAG("em"); @@ -434,7 +433,6 @@ ALLOW_TAG("h4"); ALLOW_TAG("h5"); ALLOW_TAG("h6"); - ALLOW_TAG("hr"); /* FIXME: not valid, need to skip?? */ ALLOW_TAG("html"); ALLOW_TAG_ALT("i", "em"); ALLOW_TAG_ALT("italic", "em"); @@ -447,7 +445,22 @@ ALLOW_TAG("strong"); ALLOW_TAG("ul"); - if(!g_ascii_strncasecmp(c, "<u>", 2) || !g_ascii_strncasecmp(c, "<underline>", strlen("<underline>"))) { + /* we skip <HR> because it's not legal in XHTML-IM. However, + * we still want to send something sensible, so we put a + * linebreak in its place. <BR> also needs special handling + * because putting a </BR> to close it would just be dumb. */ + if((!g_ascii_strncasecmp(c, "<br", 3) + || !g_ascii_strncasecmp(c, "<hr", 3)) + && (*(c+3) == '>' || + !g_ascii_strncasecmp(c+3, "/>", 2) || + !g_ascii_strncasecmp(c+3, " />", 3))) { + c = strchr(c, '>') + 1; + xhtml = g_string_append(xhtml, "<br/>"); + if(*c != '\n') + plain = g_string_append_c(plain, '\n'); + continue; + } + if(!g_ascii_strncasecmp(c, "<u>", 3) || !g_ascii_strncasecmp(c, "<underline>", strlen("<underline>"))) { struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); pt->src_tag = *(c+2) == '>' ? "u" : "underline"; pt->dest_tag = "span"; @@ -456,7 +469,7 @@ xhtml = g_string_append(xhtml, "<span style='text-decoration: underline;'>"); continue; } - if(!g_ascii_strncasecmp(c, "<s>", 2) || !g_ascii_strncasecmp(c, "<strike>", strlen("<strike>"))) { + if(!g_ascii_strncasecmp(c, "<s>", 3) || !g_ascii_strncasecmp(c, "<strike>", strlen("<strike>"))) { struct gaim_parse_tag *pt = g_new0(struct gaim_parse_tag, 1); pt->src_tag = *(c+2) == '>' ? "s" : "strike"; pt->dest_tag = "span"; |