[Dovecot] Japanese Search

Kazuo Moriwaka moriwaka at valinux.co.jp
Fri Dec 24 08:26:56 EET 2004


Hello,

From: Kazuo Moriwaka <moriwaka at valinux.co.jp>
Subject: Re: [Dovecot] Japanese Search
Date: Tue, 21 Dec 2004 12:30:54 +0900 (JST)

> I found a reason for imapd cannot search message body by japanese.
> charset_to_ucase_utf8_string() convert key to UTF-8 string,
> but context->charset keeps old value(ex. "iso-2022-jp").
> 
> When 2nd call of charset_to_ucase_utf8_string(), 
> charset(iso-2022-jp) and key value (utf-8 encoded string) are
> mismatch. It causes:
> -> iconv returns error
>   -> key isn't valid
>     -> search failed.

I append some descriptions..

2 calls of charset_to_ucase_utf8_string() is caused 
by commands like following:
a001 search charset ***** body "*****" 

When imapd receive it, it calls message_body_search()

Call flow is look like:

message_body_search() 
 +-> message_body_search_init()
 |   +-> charset_to_ucase_utf8_string()   <-- 1st (key is 'charset')
 +-> message_bodd_search_ctx()
     +-> message_search_header()
         +-> message_header_search_init()
             +-> charset_to_ucase_utf8_string()  <-- 2nd (key is utf-8)

My last patch is just a quick hack to avoid this.
I think search key's initialize (convert to utf8) is done in or near of
index_storage_search_init() or imap_search(). 

thanks,
-- 
Kazuo Moriwaka 
moriwaka at valinux.co.jp


More information about the dovecot mailing list