2005-11-07 [colin] 1.9.99cvs17
authorColin Leroy <colin@colino.net>
Mon, 7 Nov 2005 16:54:37 +0000 (16:54 +0000)
committerColin Leroy <colin@colino.net>
Mon, 7 Nov 2005 16:54:37 +0000 (16:54 +0000)
* src/addritem.c
* src/ldif.c
Fix import of base-64 encoded items

ChangeLog
PATCHSETS
configure.ac
src/addritem.c
src/ldif.c

index ae62b69..c1e94c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-07 [colin]     1.9.99cvs17
+
+       * src/addritem.c
+       * src/ldif.c
+               Fix import of base-64 encoded items
+
 2005-11-07 [cleroy]    1.9.99cvs16
 
        * src/send_message.c
index 9384c7f..73c950e 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.2 -r 1.3 doc/man/Makefile.am;  diff -u /dev/null doc/man/sylpheed-claws.1;  cvs diff -u -r -1.5.2.2 -r -1.5.2.3 doc/man/sylpheed.1;  ) > 1.9.99cvs14.patchset
 ( cvs diff -u -r 1.6.10.5 -r 1.6.10.6 src/mutt.c;  cvs diff -u -r 1.6.2.4 -r 1.6.2.5 src/pine.c;  ) > 1.9.99cvs15.patchset
 ( cvs diff -u -r 1.17.2.21 -r 1.17.2.22 src/send_message.c;  ) > 1.9.99cvs16.patchset
+( cvs diff -u -r 1.13.2.3 -r 1.13.2.4 src/addritem.c;  cvs diff -u -r 1.12.2.5 -r 1.12.2.6 src/ldif.c;  ) > 1.9.99cvs17.patchset
index ab5ad09..95ee968 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=99
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=16
+EXTRA_VERSION=17
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index c7832ae..0c2c3df 100644 (file)
@@ -28,6 +28,7 @@
 #include "utils.h"
 #include "addritem.h"
 #include "mgutils.h"
+#include "codeconv.h"
 
 /**
  * Create new email address item.
@@ -270,7 +271,16 @@ void addritem_person_set_id( ItemPerson *person, const gchar *value ) {
  * \param value Name.
  */
 void addritem_person_set_first_name( ItemPerson *person, const gchar *value ) {
-       person->firstName = mgu_replace_string( person->firstName, value );
+       if (!value || g_utf8_validate(value, -1, NULL))
+               person->firstName = mgu_replace_string( person->firstName, value );
+       else {
+               gchar *out = conv_codeset_strdup(value, 
+                               conv_get_locale_charset_str_no_utf8(),
+                               CS_INTERNAL);
+               if (out)
+                       person->firstName = mgu_replace_string( person->firstName, out );
+               g_free(out);
+       }
 }
 
 /**
@@ -279,7 +289,16 @@ void addritem_person_set_first_name( ItemPerson *person, const gchar *value ) {
  * \param value name.
  */
 void addritem_person_set_last_name( ItemPerson *person, const gchar *value ) {
-       person->lastName = mgu_replace_string( person->lastName, value );
+       if (!value || g_utf8_validate(value, -1, NULL))
+               person->lastName = mgu_replace_string( person->lastName, value );
+       else {
+               gchar *out = conv_codeset_strdup(value, 
+                               conv_get_locale_charset_str_no_utf8(),
+                               CS_INTERNAL);
+               if (out)
+                       person->lastName = mgu_replace_string( person->lastName, out );
+               g_free(out);
+       }
 }
 
 /**
@@ -288,7 +307,16 @@ void addritem_person_set_last_name( ItemPerson *person, const gchar *value ) {
  * \param value name.
  */
 void addritem_person_set_nick_name( ItemPerson *person, const gchar *value ) {
-       person->nickName = mgu_replace_string( person->nickName, value );
+       if (!value || g_utf8_validate(value, -1, NULL))
+               person->nickName = mgu_replace_string( person->nickName, value );
+       else {
+               gchar *out = conv_codeset_strdup(value, 
+                               conv_get_locale_charset_str_no_utf8(),
+                               CS_INTERNAL);
+               if (out)
+                       person->nickName = mgu_replace_string( person->nickName, out );
+               g_free(out);
+       }
 }
 
 /**
@@ -297,7 +325,16 @@ void addritem_person_set_nick_name( ItemPerson *person, const gchar *value ) {
  * \param value name.
  */
 void addritem_person_set_common_name( ItemPerson *person, const gchar *value ) {
-       ADDRITEM_NAME(person) = mgu_replace_string( ADDRITEM_NAME(person), value );
+       if (!value || g_utf8_validate(value, -1, NULL))
+               ADDRITEM_NAME(person) = mgu_replace_string( ADDRITEM_NAME(person), value );
+       else {
+               gchar *out = conv_codeset_strdup(value, 
+                               conv_get_locale_charset_str_no_utf8(),
+                               CS_INTERNAL);
+               if (out)
+                       ADDRITEM_NAME(person) = mgu_replace_string( ADDRITEM_NAME(person), out );
+               g_free(out);
+       }
 }
 
 /**
index 1635cda..60c277c 100644 (file)
@@ -485,6 +485,14 @@ static void ldif_build_items(
                        fullName = g_strdup_printf( "%s", lastName );
                }
        }
+       
+       if (!fullName || strlen(fullName) == 0) {
+               g_free(fullName);
+               fullName = NULL;
+               if (rec->listCName)
+                       fullName = g_strdup(rec->listCName->data);
+       }
+       
        if( fullName ) {
                g_strchug( fullName ); g_strchomp( fullName );
        }
@@ -725,7 +733,17 @@ static void ldif_read_file( LdifFile *ldifFile, AddressCache *cache ) {
                        if( lastTag ) {
                                /* Save record */
                                fullValue = mgu_list_coalesce( listValue );
-
+                               if (fullValue && last64) {
+                                       gchar *out = g_malloc(strlen(fullValue));
+                                       int len = 0;
+                                       if ((len = base64_decode(out, fullValue,
+                                                       strlen(fullValue))) >= 0) {
+                                               g_free(fullValue);
+                                               fullValue = out;
+                                               fullValue[len] = '\0';
+                                       } else
+                                               g_free(out);
+                               }
                                /* Base-64 encoded data */
                                /*
                                if( last64 ) {
@@ -766,6 +784,17 @@ static void ldif_read_file( LdifFile *ldifFile, AddressCache *cache ) {
                                                        /* Save data */
                                                        fullValue =
                                                                mgu_list_coalesce( listValue );
+                                                       if (fullValue && last64) {
+                                                               gchar *out = g_malloc(strlen(fullValue));
+                                                               int len = 0;
+                                                               if ((len = base64_decode(out, fullValue,
+                                                                               strlen(fullValue))) >= 0) {
+                                                                       g_free(fullValue);
+                                                                       fullValue = out;
+                                                                       fullValue[len] = '\0';
+                                                               } else
+                                                                       g_free(out);
+                                                       }
                                                        /* Base-64 encoded data */
                                                        /*
                                                        if( last64 ) {