[evolution-ews/gnome-3-6] Bug #692688 - Crash in strip_html_tags()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-3-6] Bug #692688 - Crash in strip_html_tags()
- Date: Mon, 28 Jan 2013 11:28:10 +0000 (UTC)
commit bbc6124445a398419e91b1f883b3efa85dfbfe13
Author: Milan Crha <mcrha redhat com>
Date: Mon Jan 28 12:27:46 2013 +0100
Bug #692688 - Crash in strip_html_tags()
src/server/e-ews-item.c | 44 ++++++++++++++++++++++++++++++++++++++------
1 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index c64905c..dff640f 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -810,14 +810,46 @@ strip_html_tags (const gchar *html_text)
{
gssize haystack_len = strlen (html_text);
gchar *plain_text = g_malloc (haystack_len);
- gchar *start = g_strstr_len (html_text, haystack_len, "<body>"),
- *end = g_strstr_len (html_text, haystack_len, "</body>"),
+ gchar *start = g_strstr_len (html_text, haystack_len, "<body"),
+ *end = g_strstr_len (html_text, haystack_len, "</body"),
*i, *j;
- for (j = plain_text, i = start + 6; i < end; i++) {
- if (*i == '&') i = i + 6;
- if (*i == '<') while (*i != '>') i++;
- else { *j = *i; j++; }
+ if (!start || !end) {
+ g_free (plain_text);
+ return g_strdup (html_text);
+ }
+
+ i = start;
+ while (i < end && *i != '>') {
+ i++;
+ }
+
+ for (j = plain_text; i < end; i++) {
+ if (*i == '&') {
+ gchar *from = i;
+
+ while (i < end && *i != ';' && *i != '<' && *i != '>')
+ i++;
+
+ if (i >= end)
+ break;
+
+ if (*i != ';')
+ i = from;
+ else
+ continue;
+ }
+
+ if (*i == '<') {
+ while (i < end && *i != '>')
+ i++;
+
+ if (i >= end)
+ break;
+ } else {
+ *j = *i;
+ j++;
+ }
}
*j = '\0';
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]