diff options
author | Dan Winship <danw@src.gnome.org> | 2001-04-25 04:00:38 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-04-25 04:00:38 +0800 |
commit | ec67eb41a73097b60135d9f85e669f66497ef127 (patch) | |
tree | 0c566d5bf693c5e00dc891f4bde3fa06adb9499a | |
parent | d67e13c5347c512ef0a405934a2e5964704fbd96 (diff) | |
download | gsoc2013-evolution-ec67eb41a73097b60135d9f85e669f66497ef127.tar.gz gsoc2013-evolution-ec67eb41a73097b60135d9f85e669f66497ef127.tar.zst gsoc2013-evolution-ec67eb41a73097b60135d9f85e669f66497ef127.zip |
If the buffer is too small, making it twice as big does not guarantee it
* e-html-utils.c (check_size): If the buffer is too small, making
it twice as big does not guarantee it will be big enough. "Duh".
Also, a bunch of the check_size calls don't seem to be taking
trailing NULs into account, so add in a +1 here.
svn path=/trunk/; revision=9549
-rw-r--r-- | e-util/ChangeLog | 7 | ||||
-rw-r--r-- | e-util/e-html-utils.c | 32 |
2 files changed, 23 insertions, 16 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 6ba0ba597e..61743701ad 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,10 @@ +2001-04-24 Dan Winship <danw@ximian.com> + + * e-html-utils.c (check_size): If the buffer is too small, making + it twice as big does not guarantee it will be big enough. "Duh". + Also, a bunch of the check_size calls don't seem to be taking + trailing NULs into account, so add in a +1 here. + 2001-04-24 Kjartan Maraas <kmaraas@gnome.org> * e-gui-utils.c, e-memory, e-msgport.c, e-pilot-map, e-sexp.c: diff --git a/e-util/e-html-utils.c b/e-util/e-html-utils.c index c9c116e754..8f15e4a39d 100644 --- a/e-util/e-html-utils.c +++ b/e-util/e-html-utils.c @@ -23,17 +23,17 @@ #include <stdio.h> #include <string.h> #include <glib.h> -#include <unicode.h> +#include <gal/unicode/gunicode.h> #include "e-html-utils.h" static char * check_size (char **buffer, int *buffer_size, char *out, int len) { - if (out + len > *buffer + *buffer_size) { + if (out + len + 1> *buffer + *buffer_size) { int index = out - *buffer; - *buffer_size *= 2; + *buffer_size = MAX (index + len + 1, *buffer_size * 2); *buffer = g_realloc (*buffer, *buffer_size); out = *buffer + index; } @@ -122,7 +122,7 @@ email_address_extract (const unsigned char **text) static gboolean is_citation (const unsigned char *c, gboolean saw_citation) { - unicode_char_t u; + gunichar u; gint i; /* A line that starts with a ">" is a citation, unless it's @@ -150,11 +150,11 @@ is_citation (const unsigned char *c, gboolean saw_citation) } /* Check for "Rupert> " and the like... */ - for (i = 0; c && *c && *c != '\n' && i < 10; i ++, c = unicode_next_utf8 (c)) { - unicode_get_utf8 (c, &u); + for (i = 0; c && *c && *c != '\n' && i < 10; i ++, c = g_utf8_next_char (c)) { + u = g_utf8_get_char (c); if (u == '>') return TRUE; - if (!unicode_isalnum (u)) + if (!g_unichar_isalnum (u)) return FALSE; } return FALSE; @@ -219,8 +219,8 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color) col = 0; - for (cur = input; cur && *cur; cur = unicode_next_utf8 (cur)) { - unicode_char_t u; + for (cur = input; cur && *cur; cur = g_utf8_next_char (cur)) { + gunichar u; if (flags & E_TEXT_TO_HTML_MARK_CITATION && col == 0) { saw_citation = is_citation (cur, saw_citation); @@ -247,8 +247,8 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color) cur++; } - unicode_get_utf8 (cur, &u); - if (unicode_isalpha (u) && + u = g_utf8_get_char (cur); + if (g_unichar_isalpha (u) && (flags & E_TEXT_TO_HTML_CONVERT_URLS)) { char *tmpurl = NULL, *refurl = NULL, *dispurl = NULL; @@ -265,7 +265,7 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color) } } else if (!strncasecmp (cur, "www.", 4) && (*(cur + 4) < 0x80) && - unicode_isalnum (*(cur + 4))) { + g_unichar_isalnum (*(cur + 4))) { tmpurl = url_extract (&cur, FALSE); dispurl = e_text_to_html (tmpurl, 0); refurl = g_strdup_printf ("http://%s", @@ -287,10 +287,10 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color) if (!*cur) break; - unicode_get_utf8 (cur, &u); + u = g_utf8_get_char (cur); } - if (unicode_isalpha (u) + if (g_unichar_isalpha (u) && (flags & E_TEXT_TO_HTML_CONVERT_ADDRESSES) && is_email_address (cur)) { gchar *addr = NULL, *dispaddr = NULL; @@ -311,11 +311,11 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color) if (!*cur) break; - unicode_get_utf8 (cur, &u); + u = g_utf8_get_char (cur); } - if (u == (unicode_char_t)-1) { + if (u == (gunichar)-1) { /* Sigh. Someone sent undeclared 8-bit data. * Assume it's iso-8859-1. */ |