aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-05-15 05:04:35 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-05-15 05:04:35 +0800
commit05817ac1224ed1fc9853095b312dfface4fd3479 (patch)
tree4c4ff84f10dce0e42dc95ff14a99dd4048439110
parentb63edae65e589775b1169e9111755f00b09bd610 (diff)
downloadgsoc2013-evolution-05817ac1224ed1fc9853095b312dfface4fd3479.tar.gz
gsoc2013-evolution-05817ac1224ed1fc9853095b312dfface4fd3479.tar.zst
gsoc2013-evolution-05817ac1224ed1fc9853095b312dfface4fd3479.zip
Replicate the semantics of the libunicode utf8 functions by returning NULL
2001-05-14 Jon Trowbridge <trow@ximian.com> * camel-search-private.c (utf8_get): Replicate the semantics of the libunicode utf8 functions by returning NULL in the arg on invalid utf8. * camel-pgp-context.c (pgp_verify): Check for valid utf8, terminate loop if something looks wrong. * camel-mime-utils.c (header_encode_phrase_get_words): Properly check for invalid utf8. (header_encode_string): Properly check for invalid utf8. * camel-charset-map.c (camel_charset_step): Properly check for invalid utf8. 2001-05-14 Jon Trowbridge <trow@ximian.com> * e-html-utils.c (is_citation): Check for bad utf8. svn path=/trunk/; revision=9798
-rw-r--r--camel/ChangeLog16
-rw-r--r--camel/camel-charset-map.c5
-rw-r--r--camel/camel-mime-utils.c13
-rw-r--r--camel/camel-pgp-context.c2
-rw-r--r--camel/camel-search-private.c2
-rw-r--r--e-util/ChangeLog4
-rw-r--r--e-util/e-html-utils.c4
7 files changed, 36 insertions, 10 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 5a42731323..41e78c0129 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,19 @@
+2001-05-14 Jon Trowbridge <trow@ximian.com>
+
+ * camel-search-private.c (utf8_get): Replicate the semantics of
+ the libunicode utf8 functions by returning NULL in the arg
+ on invalid utf8.
+
+ * camel-pgp-context.c (pgp_verify): Check for valid utf8,
+ terminate loop if something looks wrong.
+
+ * camel-mime-utils.c (header_encode_phrase_get_words): Properly
+ check for invalid utf8.
+ (header_encode_string): Properly check for invalid utf8.
+
+ * camel-charset-map.c (camel_charset_step): Properly check for
+ invalid utf8.
+
2001-05-14 Jeffrey Stedfast <fejj@ximian.com>
* tests/folder/test9.c:
diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c
index d7aa8763dd..f33c8082dd 100644
--- a/camel/camel-charset-map.c
+++ b/camel/camel-charset-map.c
@@ -227,11 +227,12 @@ camel_charset_step(CamelCharset *c, const char *in, int len)
gunichar c;
const char *newinptr;
newinptr = g_utf8_next_char(inptr);
- if (newinptr == NULL) {
+ c = g_utf8_get_char(inptr);
+ if (newinptr == NULL || !g_unichar_validate (c)) {
inptr++;
continue;
}
- c = g_utf8_get_char(inptr);
+
inptr = newinptr;
if (c<=0xffff) {
mask &= charset_mask(c);
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index fbfbb3e5be..3d915be1f7 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -1255,6 +1255,8 @@ header_encode_string (const unsigned char *in)
int encoding;
GString *out;
char *outstr;
+
+ g_return_val_if_fail (g_utf8_validate (in, -1, NULL), NULL);
if (in == NULL)
return NULL;
@@ -1281,13 +1283,14 @@ header_encode_string (const unsigned char *in)
const char *newinptr;
newinptr = g_utf8_next_char (inptr);
- if (newinptr == NULL) {
+ c = g_utf8_get_char (inptr);
+ if (newinptr == NULL || !g_unichar_validate (c)) {
w(g_warning ("Invalid UTF-8 sequence encountered (pos %d, char '%c'): %s",
(inptr-in), inptr[0], in));
inptr++;
continue;
}
- c = g_utf8_get_char (inptr);
+
if (g_unichar_isspace (c) && !last_was_space) {
/* we've reached the end of a 'word' */
@@ -1427,13 +1430,15 @@ header_encode_phrase_get_words (const unsigned char *in)
const char *newinptr;
newinptr = g_utf8_next_char (inptr);
- if (newinptr == NULL) {
+ c = g_utf8_get_char (inptr);
+
+ if (!g_unichar_validate (c)) {
w(g_warning ("Invalid UTF-8 sequence encountered (pos %d, char '%c'): %s",
(inptr - in), inptr[0], in));
inptr++;
continue;
}
- c = g_utf8_get_char (inptr);
+
inptr = newinptr;
if (g_unichar_isspace (c)) {
diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c
index c2e361ce40..c19756a135 100644
--- a/camel/camel-pgp-context.c
+++ b/camel/camel-pgp-context.c
@@ -992,7 +992,7 @@ pgp_verify (CamelCipherContext *ctx, CamelStream *istream,
inptr = diagnostics;
inend = inptr + inlen;
- while (inptr && inptr < inend) {
+ while (inptr && inptr < inend && g_unichar_validate (g_utf8_get_char (inptr))) {
*outbuf++ = g_utf8_get_char (inptr) & 0xff;
inptr = g_utf8_next_char (inptr);
}
diff --git a/camel/camel-search-private.c b/camel/camel-search-private.c
index e46cc29cc8..65f6c17ff9 100644
--- a/camel/camel-search-private.c
+++ b/camel/camel-search-private.c
@@ -200,7 +200,7 @@ utf8_get (const char **inp)
g_return_val_if_fail (p != NULL, 0);
c = g_utf8_get_char (p);
- *inp = g_utf8_next_char (p);
+ *inp = g_unichar_validate (c) ? g_utf8_next_char (p) : NULL;
return c;
}
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index abf4fcc7ee..d0cf6a5369 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,7 @@
+2001-05-14 Jon Trowbridge <trow@ximian.com>
+
+ * e-html-utils.c (is_citation): Check for bad utf8.
+
2001-05-08 Dan Winship <danw@ximian.com>
* e-path.c (e_path_find_folders): Walk a hierarchy using the
diff --git a/e-util/e-html-utils.c b/e-util/e-html-utils.c
index 1561492454..e79d5e2192 100644
--- a/e-util/e-html-utils.c
+++ b/e-util/e-html-utils.c
@@ -145,7 +145,7 @@ 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 = g_utf8_next_char (c)) {
+ for (i = 0; c && *c && g_unichar_validate (g_utf8_get_char (c)) && *c != '\n' && i < 10; i ++, c = g_utf8_next_char (c)) {
u = g_utf8_get_char (c);
if (u == '>')
return TRUE;
@@ -304,7 +304,7 @@ e_text_to_html_full (const char *input, unsigned int flags, guint32 color)
}
}
- if (u == (gunichar)-1) {
+ if (!g_unichar_validate (u)) {
/* Sigh. Someone sent undeclared 8-bit data.
* Assume it's iso-8859-1.
*/