This patch makes gaim_markup_strip_html use g_ascii_strncasecmp as someone
(marv?) pointed out it should be using a long time ago in #gaim, and makes
gaim_unescape_html also use this as entities are not case sensitive.
Adds stripping of ' in the gaim_markup_strip_html, which is needed to
stop &apos's getting into plain text logs.
It also makes gaim_escape_html escape the same set of entities that
gaim_unescape_html will unescape.
Index: util.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/util.c,v
retrieving revision 1.280
diff -u -p -u -r1.280 util.c
--- util.c 9 Apr 2004 05:30:46 -0000 1.280
+++ util.c 9 Apr 2004 11:29:04 -0000
@@ -1126,7 +1126,7 @@ gaim_markup_strip_html(const char *str)
{
if (str2[i] == '<')
{
- if (strncasecmp(str2 + i, "
", 4) == 0)
+ if (g_ascii_strncasecmp(str2 + i, "
", 4) == 0)
{
str2[j++] = '\n';
i = i + 3;
@@ -1163,28 +1163,35 @@ gaim_markup_strip_html(const char *str)
continue;
}
- if (str2[i] == '&' && strncasecmp(str2 + i, """, 6) == 0)
+ if (str2[i] == '&' && g_ascii_strncasecmp(str2 + i, "'", 6) == 0)
+ {
+ str2[j++] = '\'';
+ i = i + 5;
+ continue;
+ }
+
+ if (str2[i] == '&' && g_ascii_strncasecmp(str2 + i, """, 6) == 0)
{
str2[j++] = '\"';
i = i + 5;
continue;
}
- if (str2[i] == '&' && strncasecmp(str2 + i, "&", 5) == 0)
+ if (str2[i] == '&' && g_ascii_strncasecmp(str2 + i, "&", 5) == 0)
{
str2[j++] = '&';
i = i + 4;
continue;
}
- if (str2[i] == '&' && strncasecmp(str2 + i, "<", 4) == 0)
+ if (str2[i] == '&' && g_ascii_strncasecmp(str2 + i, "<", 4) == 0)
{
str2[j++] = '<';
i = i + 3;
continue;
}
- if (str2[i] == '&' && strncasecmp(str2 + i, ">", 4) == 0)
+ if (str2[i] == '&' && g_ascii_strncasecmp(str2 + i, ">", 4) == 0)
{
str2[j++] = '>';
i = i + 3;
@@ -1457,6 +1464,9 @@ gaim_escape_html(const char *html) {
case '"':
ret = g_string_append(ret, """);
break;
+ case '\'':
+ ret = g_string_append(ret, "'");
+ break;
default:
ret = g_string_append_c(ret, *c);
}
@@ -1478,22 +1488,22 @@ gaim_unescape_html(const char *html) {
const char *c = html;
GString *ret = g_string_new("");
while (*c) {
- if (!strncmp(c, "&", 5)) {
+ if (!g_ascii_strncasecmp(c, "&", 5)) {
ret = g_string_append_c(ret, '&');
c += 5;
- } else if (!strncmp(c, "<", 4)) {
+ } else if (!g_ascii_strncasecmp(c, "<", 4)) {
ret = g_string_append_c(ret, '<');
c += 4;
- } else if (!strncmp(c, ">", 4)) {
+ } else if (!g_ascii_strncasecmp(c, ">", 4)) {
ret = g_string_append_c(ret, '>');
c += 4;
- } else if (!strncmp(c, """, 6)) {
+ } else if (!g_ascii_strncasecmp(c, """, 6)) {
ret = g_string_append_c(ret, '"');
c += 6;
- } else if (!strncmp(c, "'", 6)) {
+ } else if (!g_ascii_strncasecmp(c, "'", 6)) {
ret = g_string_append_c(ret, '\'');
c += 6;
- } else if (!strncmp(c, "
", 4)) {
+ } else if (!g_ascii_strncasecmp(c, "
", 4)) {
ret = g_string_append_c(ret, '\n');
c += 4;
} else {