Mercurial > pidgin
comparison src/gtkimhtml.c @ 7280:f946af3b0039
[gaim-migrate @ 7859]
fix © and ® in gtkimhtml
fix a potential segfault on jabber
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 16 Oct 2003 04:17:25 +0000 |
parents | 48cc5d5d5a6c |
children | 0f7dd6715a90 |
comparison
equal
deleted
inserted
replaced
7279:0d24c94e4fbc | 7280:f946af3b0039 |
---|---|
752 (*type)++ | 752 (*type)++ |
753 | 753 |
754 | 754 |
755 static gboolean | 755 static gboolean |
756 gtk_imhtml_is_amp_escape (const gchar *string, | 756 gtk_imhtml_is_amp_escape (const gchar *string, |
757 gchar *replace, | 757 gchar **replace, |
758 gint *length) | 758 gint *length) |
759 { | 759 { |
760 static char buf[3]; | |
760 g_return_val_if_fail (string != NULL, FALSE); | 761 g_return_val_if_fail (string != NULL, FALSE); |
761 g_return_val_if_fail (replace != NULL, FALSE); | 762 g_return_val_if_fail (replace != NULL, FALSE); |
762 g_return_val_if_fail (length != NULL, FALSE); | 763 g_return_val_if_fail (length != NULL, FALSE); |
763 | 764 |
764 if (!g_ascii_strncasecmp (string, "&", 5)) { | 765 if (!g_ascii_strncasecmp (string, "&", 5)) { |
765 *replace = '&'; | 766 *replace = "&"; |
766 *length = 5; | 767 *length = 5; |
767 } else if (!g_ascii_strncasecmp (string, "<", 4)) { | 768 } else if (!g_ascii_strncasecmp (string, "<", 4)) { |
768 *replace = '<'; | 769 *replace = "<"; |
769 *length = 4; | 770 *length = 4; |
770 } else if (!g_ascii_strncasecmp (string, ">", 4)) { | 771 } else if (!g_ascii_strncasecmp (string, ">", 4)) { |
771 *replace = '>'; | 772 *replace = ">"; |
772 *length = 4; | 773 *length = 4; |
773 } else if (!g_ascii_strncasecmp (string, " ", 6)) { | 774 } else if (!g_ascii_strncasecmp (string, " ", 6)) { |
774 *replace = ' '; | 775 *replace = " "; |
775 *length = 6; | 776 *length = 6; |
776 } else if (!g_ascii_strncasecmp (string, "©", 6)) { | 777 } else if (!g_ascii_strncasecmp (string, "©", 6)) { |
777 *replace = '©'; /* was: '©' */ | 778 *replace = "©"; |
778 *length = 6; | 779 *length = 6; |
779 } else if (!g_ascii_strncasecmp (string, """, 6)) { | 780 } else if (!g_ascii_strncasecmp (string, """, 6)) { |
780 *replace = '\"'; | 781 *replace = "\""; |
781 *length = 6; | 782 *length = 6; |
782 } else if (!g_ascii_strncasecmp (string, "®", 5)) { | 783 } else if (!g_ascii_strncasecmp (string, "®", 5)) { |
783 *replace = '®'; /* was: '®' */ | 784 *replace = "®"; |
784 *length = 5; | 785 *length = 5; |
785 } else if (!g_ascii_strncasecmp (string, "'", 6)) { | 786 } else if (!g_ascii_strncasecmp (string, "'", 6)) { |
786 *replace = '\''; | 787 *replace = "\'"; |
787 *length = 6; | 788 *length = 6; |
788 } else if (*(string + 1) == '#') { | 789 } else if (*(string + 1) == '#') { |
789 guint pound = 0; | 790 guint pound = 0; |
790 if ((sscanf (string, "&#%u;", £) == 1) && pound != 0) { | 791 if ((sscanf (string, "&#%u;", £) == 1) && pound != 0) { |
791 if (*(string + 3 + (gint)log10 (pound)) != ';') | 792 if (*(string + 3 + (gint)log10 (pound)) != ';') |
792 return FALSE; | 793 return FALSE; |
793 *replace = (gchar)pound; | 794 g_snprintf(buf, sizeof(buf), "%c", (gchar)pound); |
795 *replace = buf; | |
794 *length = 2; | 796 *length = 2; |
795 while (isdigit ((gint) string [*length])) (*length)++; | 797 while (isdigit ((gint) string [*length])) (*length)++; |
796 if (string [*length] == ';') (*length)++; | 798 if (string [*length] == ';') (*length)++; |
797 } else { | 799 } else { |
798 return FALSE; | 800 return FALSE; |
896 { | 898 { |
897 gchar *t = tag; | 899 gchar *t = tag; |
898 gchar *e, *a; | 900 gchar *e, *a; |
899 gchar *val; | 901 gchar *val; |
900 gint len; | 902 gint len; |
901 gchar c; | 903 gchar *c; |
902 GString *ret; | 904 GString *ret; |
903 | 905 |
904 while (g_ascii_strncasecmp (t, opt, strlen (opt))) { | 906 while (g_ascii_strncasecmp (t, opt, strlen (opt))) { |
905 gboolean quote = FALSE; | 907 gboolean quote = FALSE; |
906 if (*t == '\0') break; | 908 if (*t == '\0') break; |
933 | 935 |
934 ret = g_string_new(""); | 936 ret = g_string_new(""); |
935 e = val; | 937 e = val; |
936 while(*e) { | 938 while(*e) { |
937 if(gtk_imhtml_is_amp_escape(e, &c, &len)) { | 939 if(gtk_imhtml_is_amp_escape(e, &c, &len)) { |
938 ret = g_string_append_c(ret, c); | 940 ret = g_string_append(ret, c); |
939 e += len; | 941 e += len; |
940 } else { | 942 } else { |
941 ret = g_string_append_c(ret, *e); | 943 ret = g_string_append_c(ret, *e); |
942 e++; | 944 e++; |
943 } | 945 } |
1035 gchar *bg = NULL; | 1037 gchar *bg = NULL; |
1036 gint len; | 1038 gint len; |
1037 gint tlen, smilelen, wpos=0; | 1039 gint tlen, smilelen, wpos=0; |
1038 gint type; | 1040 gint type; |
1039 const gchar *c; | 1041 const gchar *c; |
1040 gchar amp; | 1042 gchar *amp; |
1041 | 1043 |
1042 guint bold = 0, | 1044 guint bold = 0, |
1043 italics = 0, | 1045 italics = 0, |
1044 underline = 0, | 1046 underline = 0, |
1045 strike = 0, | 1047 strike = 0, |
1345 c += tlen; | 1347 c += tlen; |
1346 pos += tlen; | 1348 pos += tlen; |
1347 if(tag) | 1349 if(tag) |
1348 g_free(tag); /* This was allocated back in VALID_TAG() */ | 1350 g_free(tag); /* This was allocated back in VALID_TAG() */ |
1349 } else if (*c == '&' && gtk_imhtml_is_amp_escape (c, &, &tlen)) { | 1351 } else if (*c == '&' && gtk_imhtml_is_amp_escape (c, &, &tlen)) { |
1350 ws [wpos++] = amp; | 1352 while(*amp) { |
1353 ws [wpos++] = *amp++; | |
1354 } | |
1351 c += tlen; | 1355 c += tlen; |
1352 pos += tlen; | 1356 pos += tlen; |
1353 } else if (*c == '\n') { | 1357 } else if (*c == '\n') { |
1354 if (!(options & GTK_IMHTML_NO_NEWLINE)) { | 1358 if (!(options & GTK_IMHTML_NO_NEWLINE)) { |
1355 ws[wpos] = '\n'; | 1359 ws[wpos] = '\n'; |