Mercurial > pidgin.yaz
comparison src/gtkimhtml.c @ 8118:52089b055c12
[gaim-migrate @ 8822]
"Hi over there... just found another overflow while creating
patches for gaim-cvs and 0.75 for all vulnerabilities I have
found. The new overflow is in gaim_url_parse a sscanf without
sizechecks into stackbuffers.
I think you can apply the patches directly and all vulnerabilities
are gone..." -- Stefan Esser
" Using 0.75, looking at the logs for conversations I've
had since upgrading, I discovered that the formating
(font, color, size) of the text was not showing up.
Looking at the actual HTML in the log files I discovered
that the use of tags has replaced with
tags and inline CSS, this formatting shows up fine when
viewing the logs using a browser such as Mozilla, but
not in the Gaim log viewer.
Here, I fixed my own bug in 0.75 and then fixed it in 0.76cvs
so I could give you the diff.
Actually tested it in 0.76cvs, apparently all the font handling
stuff is a bit screwy, but you might as well add my work so
when it's back to normal the log viewer is consistent with the
log files." --Douglas (douglaswth) Thrift
(18:10:53) Me: look at that html patch
(18:11:02) seanegn: I did last night
(18:11:06) Me: and?
(18:12:35) Me: can it go in?
(18:17:33) ***Me senses he is being ignored
(18:18:50) seanegn: haha, no.
(18:18:59) seanegn: It looked like it should be good. Do you want to
commit it?
(18:19:04) Me: i can do that yes
(18:19:14) Me: i'm looking at if the overflow patch compiles currently
(18:19:24) seanegn: do that one too
(18:19:27) Me: :-)
(18:19:48) seanegn: Why do I have a feeling that this conversation
(including this line) is going to be part of a commit log message?
(18:19:53) seanegn: Hi, gaim-commits!
(18:19:56) Me: lol
(18:20:25) Me: *inocently* would i do that?
(18:20:31) Me: :-P
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Thu, 15 Jan 2004 23:26:07 +0000 |
parents | 42c7227d6e4d |
children | 81a63a9bff88 |
comparison
equal
deleted
inserted
replaced
8117:e280d73ed07f | 8118:52089b055c12 |
---|---|
1023 gint *type) | 1023 gint *type) |
1024 { | 1024 { |
1025 char *close; | 1025 char *close; |
1026 *type = 1; | 1026 *type = 1; |
1027 | 1027 |
1028 | 1028 |
1029 if (!(close = strchr (string, '>'))) | 1029 if (!(close = strchr (string, '>'))) |
1030 return FALSE; | 1030 return FALSE; |
1031 | 1031 |
1032 VALID_TAG ("B"); | 1032 VALID_TAG ("B"); |
1033 VALID_TAG ("BOLD"); | 1033 VALID_TAG ("BOLD"); |
1099 if (e) { | 1099 if (e) { |
1100 *len = e - string + strlen ("-->"); | 1100 *len = e - string + strlen ("-->"); |
1101 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); | 1101 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
1102 return TRUE; | 1102 return TRUE; |
1103 } | 1103 } |
1104 } | 1104 } |
1105 | 1105 |
1106 *type = -1; | 1106 *type = -1; |
1107 *len = close - string + 1; | 1107 *len = close - string + 1; |
1108 *tag = g_strndup(string, *len - 1); | 1108 *tag = g_strndup(string, *len - 1); |
1109 return TRUE; | 1109 return TRUE; |
1110 } | 1110 } |
1166 val = ret->str; | 1166 val = ret->str; |
1167 g_string_free(ret, FALSE); | 1167 g_string_free(ret, FALSE); |
1168 return val; | 1168 return val; |
1169 } | 1169 } |
1170 | 1170 |
1171 /* Inline CSS Support - Douglas Thrift */ | |
1172 static gchar* | |
1173 gtk_imhtml_get_css_opt (gchar *style, | |
1174 const gchar *opt) | |
1175 { | |
1176 gchar *t = style; | |
1177 gchar *e, *a; | |
1178 gchar *val; | |
1179 gint len; | |
1180 gchar *c; | |
1181 GString *ret; | |
1182 | |
1183 while (g_ascii_strncasecmp (t, opt, strlen (opt))) { | |
1184 // gboolean quote = FALSE; | |
1185 if (*t == '\0') break; | |
1186 while (*t && !((*t == ' ') /*&& !quote*/)) { | |
1187 /* if (*t == '\"') | |
1188 quote = ! quote;*/ | |
1189 t++; | |
1190 } | |
1191 while (*t && (*t == ' ')) t++; | |
1192 } | |
1193 | |
1194 if (!g_ascii_strncasecmp (t, opt, strlen (opt))) { | |
1195 t += strlen (opt); | |
1196 } else { | |
1197 return NULL; | |
1198 } | |
1199 | |
1200 /* if ((*t == '\"') || (*t == '\'')) { | |
1201 e = a = ++t; | |
1202 while (*e && (*e != *(t - 1))) e++; | |
1203 if (*e == '\0') { | |
1204 return NULL; | |
1205 } else | |
1206 val = g_strndup(a, e - a); | |
1207 } else { | |
1208 e = a = t; | |
1209 while (*e && !isspace ((gint) *e)) e++; | |
1210 val = g_strndup(a, e - a); | |
1211 }*/ | |
1212 | |
1213 e = a = t; | |
1214 while (*e && *e != ';') e++; | |
1215 val = g_strndup(a, e - a); | |
1216 | |
1217 ret = g_string_new(""); | |
1218 e = val; | |
1219 while(*e) { | |
1220 if(gtk_imhtml_is_amp_escape(e, &c, &len)) { | |
1221 ret = g_string_append(ret, c); | |
1222 e += len; | |
1223 } else { | |
1224 ret = g_string_append_c(ret, *e); | |
1225 e++; | |
1226 } | |
1227 } | |
1228 | |
1229 g_free(val); | |
1230 val = ret->str; | |
1231 g_string_free(ret, FALSE); | |
1232 return val; | |
1233 } | |
1171 | 1234 |
1172 GString* gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, | 1235 GString* gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, |
1173 const gchar *text, | 1236 const gchar *text, |
1174 GtkIMHtmlOptions options, | 1237 GtkIMHtmlOptions options, |
1175 GSList *images) | 1238 GSList *images) |
1427 url = NULL; | 1490 url = NULL; |
1428 ins = gtk_text_buffer_get_insert(imhtml->text_buffer); | 1491 ins = gtk_text_buffer_get_insert(imhtml->text_buffer); |
1429 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins); | 1492 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins); |
1430 } | 1493 } |
1431 break; | 1494 break; |
1432 | 1495 |
1433 case 29: /* P */ | 1496 case 29: /* P */ |
1434 case 30: /* /P */ | 1497 case 30: /* /P */ |
1435 case 31: /* H3 */ | 1498 case 31: /* H3 */ |
1436 case 32: /* /H3 */ | 1499 case 32: /* /H3 */ |
1437 case 33: /* HTML */ | 1500 case 33: /* HTML */ |
1567 case 48: /* H3 (opt) */ | 1630 case 48: /* H3 (opt) */ |
1568 case 49: /* HTML (opt) */ | 1631 case 49: /* HTML (opt) */ |
1569 case 50: /* CITE */ | 1632 case 50: /* CITE */ |
1570 case 51: /* /CITE */ | 1633 case 51: /* /CITE */ |
1571 case 56: /* SPAN (opt) */ | 1634 case 56: /* SPAN (opt) */ |
1635 /* Inline CSS Support - Douglas Thrift | |
1636 * | |
1637 * color | |
1638 * font-family | |
1639 * font-size | |
1640 */ | |
1641 { | |
1642 gchar *style, *color, *family, *size; | |
1643 GtkIMHtmlFontDetail *font, *oldfont = NULL; | |
1644 style = gtk_imhtml_get_html_opt (tag, "style="); | |
1645 | |
1646 if (!style) break; | |
1647 | |
1648 color = gtk_imhtml_get_css_opt (style, "color: "); | |
1649 family = gtk_imhtml_get_css_opt (style, | |
1650 "font-family: "); | |
1651 size = gtk_imhtml_get_css_opt (style, "font-size: "); | |
1652 | |
1653 if (!(color || family || size)) break; | |
1654 | |
1655 if (url) | |
1656 gtk_imhtml_insert_link(imhtml, url, ws); | |
1657 else | |
1658 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos); | |
1659 ws[0] = '\0'; wpos = 0; | |
1660 //NEW_BIT (NEW_TEXT_BIT); | |
1661 | |
1662 font = g_new0 (GtkIMHtmlFontDetail, 1); | |
1663 if (fonts) | |
1664 oldfont = fonts->data; | |
1665 | |
1666 if (color && !(options & GTK_IMHTML_NO_COLOURS)) | |
1667 font->fore = color; | |
1668 else if (oldfont && oldfont->fore) | |
1669 font->fore = g_strdup(oldfont->fore); | |
1670 | |
1671 if (oldfont && oldfont->back) | |
1672 font->back = g_strdup(oldfont->back); | |
1673 | |
1674 if (family && !(options & GTK_IMHTML_NO_FONTS)) | |
1675 font->face = family; | |
1676 else if (oldfont && oldfont->face) | |
1677 font->face = g_strdup(oldfont->face); | |
1678 if (font->face && (atoi(font->face) > 100)) { | |
1679 g_free(font->face); | |
1680 font->face = g_strdup("100"); | |
1681 } | |
1682 | |
1683 if (oldfont && oldfont->sml) | |
1684 font->sml = g_strdup(oldfont->sml); | |
1685 | |
1686 if (size && !(options & GTK_IMHTML_NO_SIZES)) { | |
1687 if (g_ascii_strcasecmp(size, "smaller") == 0) | |
1688 { | |
1689 font->size = 2; | |
1690 } | |
1691 else if (g_ascii_strcasecmp(size, "larger") == 0) | |
1692 { | |
1693 font->size = 4; | |
1694 } | |
1695 else | |
1696 { | |
1697 font->size = 3; | |
1698 } | |
1699 } else if (oldfont) | |
1700 font->size = oldfont->size; | |
1701 | |
1702 g_free(style); | |
1703 g_free(size); | |
1704 fonts = g_slist_prepend (fonts, font); | |
1705 } | |
1706 break; | |
1572 case 57: /* /SPAN */ | 1707 case 57: /* /SPAN */ |
1708 /* Inline CSS Support - Douglas Thrift */ | |
1709 if (fonts) { | |
1710 GtkIMHtmlFontDetail *font = fonts->data; | |
1711 if (url) | |
1712 gtk_imhtml_insert_link(imhtml, url, ws); | |
1713 else | |
1714 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos); | |
1715 ws[0] = '\0'; wpos = 0; | |
1716 //NEW_BIT (NEW_TEXT_BIT); | |
1717 fonts = g_slist_remove (fonts, font); | |
1718 if (font->face) | |
1719 g_free (font->face); | |
1720 if (font->fore) | |
1721 g_free (font->fore); | |
1722 if (font->back) | |
1723 g_free (font->back); | |
1724 if (font->sml) | |
1725 g_free (font->sml); | |
1726 g_free (font); | |
1727 } | |
1728 break; | |
1573 case 60: /* SPAN */ | 1729 case 60: /* SPAN */ |
1574 break; | 1730 break; |
1575 case 62: /* comment */ | 1731 case 62: /* comment */ |
1576 //NEW_BIT (NEW_TEXT_BIT); | 1732 //NEW_BIT (NEW_TEXT_BIT); |
1577 if (imhtml->show_comments) | 1733 if (imhtml->show_comments) |