[Commits] [SCM] claws branch, master, updated. 3.9.3-199-gd0c64a0

colin at claws-mail.org colin at claws-mail.org
Sun May 18 20:42:58 CEST 2014


The branch master of project "claws" (Claws Mail) has been updated
       via  d0c64a09767e097b52264d247b0c9a6486c92509 (commit)
       via  373d079b4f9ac62ae1f9eaca202f29f9d4ed6b4a (commit)
      from  296282805f6b8485f80f5b9f7e696b1da2049dd2 (commit)


- Log -----------------------------------------------------------------
commit d0c64a09767e097b52264d247b0c9a6486c92509
Author: Colin Leroy <colin at colino.net>
Date:   Sun May 18 20:42:04 2014 +0200

    Fix bug 3039 more - Why read line by line?

diff --git a/src/html.c b/src/html.c
index 874b595..db01262 100644
--- a/src/html.c
+++ b/src/html.c
@@ -440,11 +440,13 @@ static SC_HTMLState sc_html_read_line(SC_HTMLParser *parser)
 	gchar buf[SC_HTMLBUFSIZE];
 	gchar buf2[SC_HTMLBUFSIZE];
 	gint index;
+	gint n;
 
 	if (parser->fp == NULL)
 		return SC_HTML_EOF;
 
-	if (fgets(buf, sizeof(buf), parser->fp) == NULL) {
+	n = fread(buf, 1, sizeof(buf), parser->fp);
+	if (n == 0) {
 		parser->state = SC_HTML_EOF;
 		return SC_HTML_EOF;
 	}

commit 373d079b4f9ac62ae1f9eaca202f29f9d4ed6b4a
Author: Colin Leroy <colin at colino.net>
Date:   Sun May 18 20:40:04 2014 +0200

    Fix bug 3039, very long parsing time in HTML email. Avoid strcasestr
    on very long buffers.

diff --git a/src/html.c b/src/html.c
index 010cf12..874b595 100644
--- a/src/html.c
+++ b/src/html.c
@@ -745,6 +745,22 @@ static void sc_html_parse_special(SC_HTMLParser *parser)
 	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;
@@ -762,14 +778,14 @@ static void sc_html_get_parenthesis(SC_HTMLParser *parser, gchar *buf, gint len)
 	}
 	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;

-----------------------------------------------------------------------

Summary of changes:
 src/html.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list