/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
{
SC_HTMLParser *parser;
- g_return_val_if_fail(fp != NULL, NULL);
- g_return_val_if_fail(conv != NULL, NULL);
+ cm_return_val_if_fail(fp != NULL, NULL);
+ cm_return_val_if_fail(conv != NULL, NULL);
parser = g_new0(SC_HTMLParser, 1);
parser->fp = fp;
gchar *tmp;
guchar *tmpp;
- g_return_val_if_fail(str != NULL, NULL);
+ cm_return_val_if_fail(str != NULL, NULL);
if (*str == '\0' || *str == '!') return NULL;
const gchar *val;
parser->state = SC_HTML_UNKNOWN;
- g_return_if_fail(*parser->bufp == '&');
+ cm_return_if_fail(*parser->bufp == '&');
/* &foo; */
for (n = 0; parser->bufp[n] != '\0' && parser->bufp[n] != ';'; n++)
sc_html_append_str(parser, symbol_name, -1);
}
+static gchar *sc_html_find_tag(SC_HTMLParser *parser, const gchar *tag)
+{
+ gchar *cur = parser->bufp;
+ gint len = strlen(tag);
+
+ if (cur == NULL)
+ return NULL;
+
+ while ((cur = strstr(cur, "<")) != NULL) {
+ if (!g_ascii_strncasecmp(cur, tag, len))
+ return cur;
+ cur += 2;
+ }
+ return NULL;
+}
+
static void sc_html_get_parenthesis(SC_HTMLParser *parser, gchar *buf, gint len)
{
gchar *p;
buf[0] = '\0';
- g_return_if_fail(*parser->bufp == '<');
+ cm_return_if_fail(*parser->bufp == '<');
/* ignore comment / CSS / script stuff */
if (!strncmp(parser->bufp, "<!--", 4)) {
}
if (!g_ascii_strncasecmp(parser->bufp, "<style", 6)) {
parser->bufp += 6;
- while ((p = strcasestr(parser->bufp, "</style>")) == NULL)
+ while ((p = sc_html_find_tag(parser, "</style>")) == NULL)
if (sc_html_read_line(parser) == SC_HTML_EOF) return;
parser->bufp = p + 8;
return;
}
if (!g_ascii_strncasecmp(parser->bufp, "<script", 7)) {
parser->bufp += 7;
- while ((p = strcasestr(parser->bufp, "</script>")) == NULL)
+ while ((p = sc_html_find_tag(parser, "</script>")) == NULL)
if (sc_html_read_line(parser) == SC_HTML_EOF) return;
parser->bufp = p + 9;
return;