dovecot: Use message_header_decode_utf8() instead of implementin...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jul 20 12:11:55 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/9607369b6bce
changeset: 6119:9607369b6bce
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jul 20 12:11:51 2007 +0300
description:
Use message_header_decode_utf8() instead of implementing our own.

diffstat:

1 file changed, 2 insertions(+), 35 deletions(-)
src/lib-imap/imap-base-subject.c |   37 ++-----------------------------------

diffs (54 lines):

diff -r 841b052e269e -r 9607369b6bce src/lib-imap/imap-base-subject.c
--- a/src/lib-imap/imap-base-subject.c	Fri Jul 20 12:02:45 2007 +0300
+++ b/src/lib-imap/imap-base-subject.c	Fri Jul 20 12:11:51 2007 +0300
@@ -8,39 +8,6 @@
 #include "charset-utf8.h"
 #include "message-header-decode.h"
 #include "imap-base-subject.h"
-
-static bool header_decode(const unsigned char *data, size_t size,
-			  const char *charset, void *context)
-{
-	buffer_t *buf = context;
-        struct charset_translation *t;
-	unsigned char *buf_data;
-	size_t pos, used_size;
-
-	pos = buffer_get_used_size(buf);
-	if (charset == NULL) {
-		/* It's ASCII. */
-		buffer_append(buf, data, size);
-	} else {
-		t = charset_to_utf8_begin(charset, TRUE, NULL);
-		if (t != NULL) {
-			(void)charset_to_utf8(t, data, &size, buf);
-                        charset_to_utf8_end(&t);
-		}
-	}
-
-	if (size > 0) {
-		/* @UNSAFE: uppercase it. Current draft specifies that we
-		   should touch only ASCII. */
-		buf_data = buffer_get_modifiable_data(buf, &used_size);
-		for (; pos < used_size; pos++) {
-			if (buf_data[pos] >= 'a' && buf_data[pos] <= 'z')
-				buf_data[pos] = buf_data[pos] - 'a' + 'A';
-		}
-	}
-
-	return TRUE;
-}
 
 static void pack_whitespace(buffer_t *buf)
 {
@@ -246,8 +213,8 @@ const char *imap_get_base_subject_cased(
 	/* (1) Convert any RFC 2047 encoded-words in the subject to
 	   UTF-8.  Convert all tabs and continuations to space.
 	   Convert all multiple spaces to a single space. */
-	message_header_decode((const unsigned char *)subject, subject_len,
-			      header_decode, buf);
+	message_header_decode_utf8((const unsigned char *)subject, subject_len,
+				   buf, TRUE);
 	buffer_append_c(buf, '\0');
 
 	pack_whitespace(buf);


More information about the dovecot-cvs mailing list