sync with 0.9.0cvs4
authorPaul Mangan <paul@claws-mail.org>
Tue, 20 May 2003 14:55:24 +0000 (14:55 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 20 May 2003 14:55:24 +0000 (14:55 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/imap.c

index 188ff77..ead2547 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-05-20
+
+       * src/imap.c: imap_locale_to_modified_utf7(): fixed the encoding bug
+         when locale strings include '+'.
+         imap_modified_utf7_to_locale()
+         imap_locale_to_modified_utf7(): at least escape/unescape '&' even
+         if iconv() is not supported.
+
 2003-05-20
 
        * src/compose.c:
index 149f3a3..99a1434 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-20 [paul]      0.8.11claws169
+
+       * sync with 0.9.0cvs4
+               see ChangeLog 2003-05-20
+               fixes bug #152, 'encoding of IMAP folders names'
+
 2003-05-20 [paul]      0.8.11claws168
 
        * sync with 0.9.0cvs3
index 2634c62..9757c8f 100644 (file)
@@ -1,3 +1,12 @@
+2003-05-20
+
+       * src/imap.c: imap_locale_to_modified_utf7(): locale Ê¸»úÎ󤬠'+'
+         ¤ò´Þ¤à¾ì¹ç¤Î¥¨¥ó¥³¡¼¥É¤Î¥Ð¥°¤ò½¤Àµ¡£
+         imap_modified_utf7_to_locale()
+         imap_locale_to_modified_utf7(): ¤¿¤È¤¨ iconv() ¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ
+         ¤¤¤Ê¤«¤Ã¤¿¤È¤·¤Æ¤â¾¯¤Ê¤¯¤È¤â '&' ¤ò¥¨¥¹¥±¡¼¥×/¥¨¥¹¥±¡¼¥×²ò½ü¤¹¤ë
+         ¤è¤¦¤Ë¤·¤¿¡£
+
 2003-05-20
 
        * src/compose.c:
index 625126e..20e3b37 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws168
+EXTRA_VERSION=claws169
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 9624923..412abb1 100644 (file)
@@ -2908,7 +2908,22 @@ static void imap_path_separator_subst(gchar *str, gchar separator)
 static gchar *imap_modified_utf7_to_locale(const gchar *mutf7_str)
 {
 #if !HAVE_ICONV
-       return g_strdup(mutf7_str);
+       const gchar *from_p;
+       gchar *to, *to_p;
+
+       to = g_malloc(strlen(mutf7_str) + 1);
+       to_p = to;
+
+       while (from_p = mutf7_str; *from_p != '\0'; from_p++) {
+               if (*from_p == '&' && *(from_p + 1) == '-') {
+                       *to_p++ = '&';
+                       from_p++;
+               } else
+                       *to_p++ = *from_p;
+       }
+       *to_p = '\0';
+
+       return to;
 #else
        static iconv_t cd = (iconv_t)-1;
        static gboolean iconv_ok = TRUE;
@@ -2982,7 +2997,22 @@ static gchar *imap_modified_utf7_to_locale(const gchar *mutf7_str)
 static gchar *imap_locale_to_modified_utf7(const gchar *from)
 {
 #if !HAVE_ICONV
-       return g_strdup(from);
+       const gchar *from_p;
+       gchar *to, *to_p;
+
+       to = g_malloc(strlen(from) * 2 + 1);
+       to_p = to;
+
+       while (from_p = from; *from_p != '\0'; from_p++) {
+               if (*from_p == '&') {
+                       *to_p++ = '&';
+                       *to_p++ = '-';
+               } else
+                       *to_p++ = *from_p;
+       }
+       *to_p = '\0';
+
+       return to;
 #else
        static iconv_t cd = (iconv_t)-1;
        static gboolean iconv_ok = TRUE;
@@ -3013,22 +3043,37 @@ static gchar *imap_locale_to_modified_utf7(const gchar *from)
 #define IS_PRINT(ch) (isprint(ch) && isascii(ch))
 
        while (from_len > 0) {
-               if (IS_PRINT(*from_tmp)) {
+               if (*from_tmp == '+') {
+                       *norm_utf7_p++ = '+';
+                       *norm_utf7_p++ = '-';
+                       norm_utf7_len -= 2;
+                       from_tmp++;
+                       from_len--;
+               } else if (IS_PRINT(*from_tmp)) {
                        /* printable ascii char */
                        *norm_utf7_p = *from_tmp;
                        norm_utf7_p++;
+                       norm_utf7_len--;
                        from_tmp++;
                        from_len--;
                } else {
-                       size_t mblen;
+                       size_t mb_len = 0, conv_len = 0;
 
                        /* unprintable char: convert to UTF-7 */
-                       for (mblen = 0;
-                            !IS_PRINT(from_tmp[mblen]) && mblen < from_len;
-                            mblen++)
-                               ;
-                       from_len -= mblen;
-                       if (iconv(cd, (ICONV_CONST gchar **)&from_tmp, &mblen,
+                       p = from_tmp;
+                       while (!IS_PRINT(*p) && conv_len < from_len) {
+                               mb_len = mblen(p, MB_LEN_MAX);
+                               if (mb_len <= 0) {
+                                       g_warning("wrong multibyte sequence\n");
+                                       return g_strdup(from);
+                               }
+                               conv_len += mb_len;
+                               p += mb_len;
+                       }
+
+                       from_len -= conv_len;
+                       if (iconv(cd, (ICONV_CONST gchar **)&from_tmp,
+                                 &conv_len,
                                  &norm_utf7_p, &norm_utf7_len) == -1) {
                                g_warning("iconv cannot convert %s to UTF-7\n",
                                          conv_get_current_charset_str());
@@ -3047,17 +3092,23 @@ static gchar *imap_locale_to_modified_utf7(const gchar *from)
        for (p = norm_utf7; p < norm_utf7_p; p++) {
                /* replace: '&' -> "&-",
                            '+' -> '&',
-                           escaped '/' -> ',' */
+                           "+-" -> '+',
+                           BASE64 '/' -> ',' */
                if (!in_escape && *p == '&') {
                        g_string_append(to_str, "&-");
                } else if (!in_escape && *p == '+') {
-                       g_string_append_c(to_str, '&');
-                       in_escape = TRUE;
+                       if (*(p + 1) == '-') {
+                               g_string_append_c(to_str, '+');
+                               p++;
+                       } else {
+                               g_string_append_c(to_str, '&');
+                               in_escape = TRUE;
+                       }
                } else if (in_escape && *p == '/') {
                        g_string_append_c(to_str, ',');
                } else if (in_escape && *p == '-') {
-                       in_escape = FALSE;
                        g_string_append_c(to_str, '-');
+                       in_escape = FALSE;
                } else {
                        g_string_append_c(to_str, *p);
                }