author | alwin <alwin> | 2003-12-25 02:10:29 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-25 02:10:29 (UTC) |
commit | af6b80a3d184e8984575a2cf7741058302c1c30b (patch) (unidiff) | |
tree | f6f66284fd9f1fd3403b188c1a1afae58ec951dc /noncore/net | |
parent | 52ccb19535d332f38dcd49f9d115192668c45357 (diff) | |
download | opie-af6b80a3d184e8984575a2cf7741058302c1c30b.zip opie-af6b80a3d184e8984575a2cf7741058302c1c30b.tar.gz opie-af6b80a3d184e8984575a2cf7741058302c1c30b.tar.bz2 |
fixed an address parsing bug
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 39 | ||||
-rw-r--r-- | noncore/net/mail/smtpwrapper.cpp | 39 |
2 files changed, 70 insertions, 8 deletions
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 21992b4..285561c 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -78,26 +78,54 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) | |||
78 | mailimf_address_list *addresses; | 78 | mailimf_address_list *addresses; |
79 | 79 | ||
80 | if ( addr.isEmpty() ) return NULL; | 80 | if ( addr.isEmpty() ) return NULL; |
81 | 81 | ||
82 | addresses = mailimf_address_list_new_empty(); | 82 | addresses = mailimf_address_list_new_empty(); |
83 | 83 | ||
84 | QStringList list = QStringList::split( ',', addr ); | 84 | bool literal_open = false; |
85 | unsigned int startpos = 0; | ||
86 | QStringList list; | ||
87 | QString s; | ||
88 | unsigned int i = 0; | ||
89 | for (; i < addr.length();++i) { | ||
90 | switch (addr[i]) { | ||
91 | case '\"': | ||
92 | literal_open = !literal_open; | ||
93 | break; | ||
94 | case ',': | ||
95 | if (!literal_open) { | ||
96 | s = addr.mid(startpos,i-startpos); | ||
97 | if (!s.isEmpty()) { | ||
98 | list.append(s); | ||
99 | qDebug("Appended %s",s.latin1()); | ||
100 | } | ||
101 | // !!!! this is a MUST BE! | ||
102 | startpos = ++i; | ||
103 | } | ||
104 | break; | ||
105 | default: | ||
106 | break; | ||
107 | } | ||
108 | } | ||
109 | s = addr.mid(startpos,i-startpos); | ||
110 | if (!s.isEmpty()) { | ||
111 | list.append(s); | ||
112 | qDebug("Appended %s",s.latin1()); | ||
113 | } | ||
85 | QStringList::Iterator it; | 114 | QStringList::Iterator it; |
86 | for ( it = list.begin(); it != list.end(); it++ ) { | 115 | for ( it = list.begin(); it != list.end(); it++ ) { |
87 | char *str = strdup( (*it).latin1() ); | 116 | char *str = strdup( (*it).latin1() ); |
88 | int err = mailimf_address_list_add_parse( addresses, str ); | 117 | int err = mailimf_address_list_add_parse( addresses, str ); |
89 | if ( err != MAILIMF_NO_ERROR ) { | 118 | if ( err != MAILIMF_NO_ERROR ) { |
90 | qDebug( "Error parsing" ); | 119 | qDebug( "Error parsing" ); |
91 | qDebug( *it ); | 120 | qDebug( *it ); |
92 | free( str ); | 121 | free( str ); |
93 | } else { | 122 | } else { |
94 | qDebug( "Parse success! :)" ); | 123 | qDebug( "Parse success! %s",(*it).latin1()); |
95 | } | 124 | } |
96 | } | 125 | } |
97 | |||
98 | return addresses; | 126 | return addresses; |
99 | } | 127 | } |
100 | 128 | ||
101 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) | 129 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) |
102 | { | 130 | { |
103 | mailimf_fields *fields; | 131 | mailimf_fields *fields; |
@@ -622,13 +650,16 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou | |||
622 | err = mailsmtp_auth( session, user, pass ); | 650 | err = mailsmtp_auth( session, user, pass ); |
623 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); | 651 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); |
624 | qDebug( "Done auth!" ); | 652 | qDebug( "Done auth!" ); |
625 | } | 653 | } |
626 | 654 | ||
627 | err = mailsmtp_send( session, from, rcpts, data, size ); | 655 | err = mailsmtp_send( session, from, rcpts, data, size ); |
628 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} | 656 | if ( err != MAILSMTP_NO_ERROR ) { |
657 | qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); | ||
658 | result = 0; goto free_con_session; | ||
659 | } | ||
629 | 660 | ||
630 | qDebug( "Mail sent." ); | 661 | qDebug( "Mail sent." ); |
631 | storeMail(data,size,"Sent"); | 662 | storeMail(data,size,"Sent"); |
632 | 663 | ||
633 | free_con_session: | 664 | free_con_session: |
634 | mailsmtp_quit( session ); | 665 | mailsmtp_quit( session ); |
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp index 21992b4..285561c 100644 --- a/noncore/net/mail/smtpwrapper.cpp +++ b/noncore/net/mail/smtpwrapper.cpp | |||
@@ -78,26 +78,54 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) | |||
78 | mailimf_address_list *addresses; | 78 | mailimf_address_list *addresses; |
79 | 79 | ||
80 | if ( addr.isEmpty() ) return NULL; | 80 | if ( addr.isEmpty() ) return NULL; |
81 | 81 | ||
82 | addresses = mailimf_address_list_new_empty(); | 82 | addresses = mailimf_address_list_new_empty(); |
83 | 83 | ||
84 | QStringList list = QStringList::split( ',', addr ); | 84 | bool literal_open = false; |
85 | unsigned int startpos = 0; | ||
86 | QStringList list; | ||
87 | QString s; | ||
88 | unsigned int i = 0; | ||
89 | for (; i < addr.length();++i) { | ||
90 | switch (addr[i]) { | ||
91 | case '\"': | ||
92 | literal_open = !literal_open; | ||
93 | break; | ||
94 | case ',': | ||
95 | if (!literal_open) { | ||
96 | s = addr.mid(startpos,i-startpos); | ||
97 | if (!s.isEmpty()) { | ||
98 | list.append(s); | ||
99 | qDebug("Appended %s",s.latin1()); | ||
100 | } | ||
101 | // !!!! this is a MUST BE! | ||
102 | startpos = ++i; | ||
103 | } | ||
104 | break; | ||
105 | default: | ||
106 | break; | ||
107 | } | ||
108 | } | ||
109 | s = addr.mid(startpos,i-startpos); | ||
110 | if (!s.isEmpty()) { | ||
111 | list.append(s); | ||
112 | qDebug("Appended %s",s.latin1()); | ||
113 | } | ||
85 | QStringList::Iterator it; | 114 | QStringList::Iterator it; |
86 | for ( it = list.begin(); it != list.end(); it++ ) { | 115 | for ( it = list.begin(); it != list.end(); it++ ) { |
87 | char *str = strdup( (*it).latin1() ); | 116 | char *str = strdup( (*it).latin1() ); |
88 | int err = mailimf_address_list_add_parse( addresses, str ); | 117 | int err = mailimf_address_list_add_parse( addresses, str ); |
89 | if ( err != MAILIMF_NO_ERROR ) { | 118 | if ( err != MAILIMF_NO_ERROR ) { |
90 | qDebug( "Error parsing" ); | 119 | qDebug( "Error parsing" ); |
91 | qDebug( *it ); | 120 | qDebug( *it ); |
92 | free( str ); | 121 | free( str ); |
93 | } else { | 122 | } else { |
94 | qDebug( "Parse success! :)" ); | 123 | qDebug( "Parse success! %s",(*it).latin1()); |
95 | } | 124 | } |
96 | } | 125 | } |
97 | |||
98 | return addresses; | 126 | return addresses; |
99 | } | 127 | } |
100 | 128 | ||
101 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) | 129 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) |
102 | { | 130 | { |
103 | mailimf_fields *fields; | 131 | mailimf_fields *fields; |
@@ -622,13 +650,16 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou | |||
622 | err = mailsmtp_auth( session, user, pass ); | 650 | err = mailsmtp_auth( session, user, pass ); |
623 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); | 651 | if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); |
624 | qDebug( "Done auth!" ); | 652 | qDebug( "Done auth!" ); |
625 | } | 653 | } |
626 | 654 | ||
627 | err = mailsmtp_send( session, from, rcpts, data, size ); | 655 | err = mailsmtp_send( session, from, rcpts, data, size ); |
628 | if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} | 656 | if ( err != MAILSMTP_NO_ERROR ) { |
657 | qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); | ||
658 | result = 0; goto free_con_session; | ||
659 | } | ||
629 | 660 | ||
630 | qDebug( "Mail sent." ); | 661 | qDebug( "Mail sent." ); |
631 | storeMail(data,size,"Sent"); | 662 | storeMail(data,size,"Sent"); |
632 | 663 | ||
633 | free_con_session: | 664 | free_con_session: |
634 | mailsmtp_quit( session ); | 665 | mailsmtp_quit( session ); |