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/mail | |
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 | |||
@@ -83,3 +83,32 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) | |||
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; |
@@ -93,6 +122,5 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) | |||
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; |
@@ -627,3 +655,6 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou | |||
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 | ||
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 | |||
@@ -83,3 +83,32 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) | |||
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; |
@@ -93,6 +122,5 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) | |||
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; |
@@ -627,3 +655,6 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou | |||
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 | ||