Summary: | Problem parsing to, cc fields | ||
---|---|---|---|
Product: | [Applications] kmail | Reporter: | Devendra Deshpande <devendra> |
Component: | general | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | RESOLVED WORKSFORME | ||
Severity: | normal | CC: | kollix |
Priority: | NOR | ||
Version: | 1.7.1 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Solaris | ||
Latest Commit: | Version Fixed In: |
Description
Devendra Deshpande
2004-11-22 06:37:49 UTC
how did you manage to recieve an email without a domain part? or am I missing something obvious here? > ------- Additional Comments From matt fruitsalad org 2005-02-18 19:37
> ------- how did you manage to recieve an email without a domain part?
> or am I missing something obvious here?
No, these are internal emails. And I suppose there's a sendmail option
to strip out the common domain. So I can send an email to <devendra> and
it will reach me perfectly ok. Moreover, I see it as <devendra> and not
devendra@localhost or anything like that.
Please note that a lot of early emailers (like sun's mailtool) simply
sent all the fields to sendmail, without adding the localhost or the
default domain like Kmail or mozilla does.
And I happen to have archives going back to 1996 :-)
Thanks,
Devendra
CVS commit by mdouhan: Parse and validate the email addresses in the to, cc and bcc fields this means that it is not so easy to mistype an email address and thus causing strange errors, for example unbalanced > are not allowed and many other cases are also caught by this validation. BUG:95183 BUG:29571 BUG:93703 BUG:71680 BUG:74032 BUG:79169 M +37 -0 kmcomposewin.cpp 1.921 M +21 -0 kmmessage.cpp 1.518 M +14 -0 kmmessage.h 1.179 --- kdepim/kmail/kmmessage.h #1.178:1.179 @@ -16,4 +16,6 @@ #include <kmime_mdn.h> +#include<libemailfunctions/email.h> + template <typename T> class QValueList; @@ -378,4 +380,16 @@ public: /** + Validate a list of email addresses, and also allow + aliases and distribution lists to be expanded + before validation. + Returns the broken address in question. + FIXME: this should be in libemailfucntions but that + requires moving expandAliases and all that + it brings + */ + static KPIM::EmailParseResult isValidEmailAddressList( const QString& aStr, + QString& brokenAddress ); + + /** Get a hash of the subject. Used for threading. --- kdepim/kmail/kmmessage.cpp #1.517:1.518 @@ -242,4 +242,25 @@ void KMMessage::setUnencryptedMsg( KMMes //----------------------------------------------------------------------------- +//FMD +//FIXME: move to libemailfunctions +KPIM::EmailParseResult KMMessage::isValidEmailAddressList( const QString& aStr, + QString& brokenAddress ) +{ + if ( aStr.isEmpty() ) { + return KPIM::AddressEmpty; + } + + QStringList list = KPIM::splitEmailAddrList( aStr ); + for( QStringList::const_iterator it = list.begin(); it != list.end(); ++it ) { + KPIM::EmailParseResult errorCode = KPIM::isValidEmailAddress( *it ); + if ( errorCode != KPIM::AddressOk ) { + brokenAddress = ( *it ); + return errorCode; + } + } + return KPIM::AddressOk; +} + +//----------------------------------------------------------------------------- const DwString& KMMessage::asDwString() const { --- kdepim/kmail/kmcomposewin.cpp #1.920:1.921 @@ -3559,4 +3559,41 @@ void KMComposeWin::doSend(int aSendNow, } + // Validate the To:, CC: and BCC fields + if ( !to().isEmpty() ) { + QString brokenAddress; + KPIM::EmailParseResult errorCode = KMMessage::isValidEmailAddressList( KMMessage::expandAliases( to()), brokenAddress ); + if ( errorCode != KPIM::AddressOk ) { + QString errorMsg( "<qt><p><b>" + brokenAddress + + "</b></p><p>" + KPIM::emailParseResultToString( errorCode ) + + "</p></qt>" ); + KMessageBox::sorry( this, errorMsg, i18n("Invalid Email Address") ); + return; + } + } + + if ( !cc().isEmpty() ) { + QString brokenAddress; + KPIM::EmailParseResult errorCode = KMMessage::isValidEmailAddressList( KMMessage::expandAliases( cc()), brokenAddress); + if ( errorCode != KPIM::AddressOk ) { + QString errorMsg( "<qt><p><b>" + brokenAddress + + "</b></p><p>" + KPIM::emailParseResultToString( errorCode ) + + "</p></qt>" ); + KMessageBox::sorry( this, errorMsg, i18n("Invalid Email Address") ); + return; + } + } + + if ( !bcc().isEmpty() ) { + QString brokenAddress; + KPIM::EmailParseResult errorCode = KMMessage::isValidEmailAddressList( KMMessage::expandAliases( bcc()), brokenAddress); + if ( errorCode != KPIM::AddressOk ) { + QString errorMsg( "<qt><p><b>" + brokenAddress + + "</b></p><p>" + KPIM::emailParseResultToString( errorCode ) + + "</p></qt>" ); + KMessageBox::sorry( this, errorMsg, i18n("Invalid Email Address") ); + return; + } + } + if (subject().isEmpty()) { On 20 Feb 2005 13:24:55 -0000 Matt Douhan <matt@fruitsalad.org> wrote: > [ S N I P P E D the patch ] I tried back porting the patch to KDE 3.3.2, and it doesn't seem to work there. My messages, with addresses split over lines, not containing any <>, are still not parsed properly. Or is that the patch works only on head? Thanks, Devendra My apologies, closing this bug was a mistake, I am reopening it again. works in KDE 4.3 |