Fix QString::at(0) on possibly empty headers by checking the size.

There is some more refactoring needed though - but let's do one
step after another.

svn path=/trunk/KDE/kdepim/; revision=469804
wilder-work
Andreas Gungl 21 years ago
parent 99cad9ca49
commit ec243adffd
  1. 11
      kmacctlocal.cpp
  2. 8
      kmacctmaildir.cpp
  3. 9
      kmmessage.cpp

@ -223,13 +223,10 @@ bool KMAcctLocal::fetchMsg()
#endif
msg->setStatus( msg->headerField( "Status" ).latin1(),
msg->headerField( "X-Status" ).latin1());
// FIXME Empty headers give a QString with size == 0 which results in an assertion
// in QString::at() because of Q_ASSERT(i >= 0 && i < size()) although
// size == 0 should return '\0' as described in QString::size() documentation
// If it's no bug in qt-copy, then we have to check for the size ourself.
// At least, commenting the next two lines lets you receive mail from a local acocunt!
//msg->setEncryptionStateChar( msg->headerField( "X-KMail-EncryptionState" ).at(0) );
//msg->setSignatureStateChar( msg->headerField( "X-KMail-SignatureState" ).at(0));
if ( msg->headerField( "X-KMail-EncryptionState" ).size() )
msg->setEncryptionStateChar( msg->headerField( "X-KMail-EncryptionState" ).at(0) );
if ( msg->headerField( "X-KMail-SignatureState" ).size() )
msg->setSignatureStateChar( msg->headerField( "X-KMail-SignatureState" ).at(0));
msg->setComplete(true);
msg->updateAttachmentState();

@ -168,9 +168,11 @@ void KMAcctMaildir::processNewMail(bool)
if (msg)
{
msg->setStatus(msg->headerField("Status").latin1(),
msg->headerField("X-Status").latin1());
msg->setEncryptionStateChar( msg->headerField( "X-KMail-EncryptionState" ).at(0));
msg->setSignatureStateChar( msg->headerField( "X-KMail-SignatureState" ).at(0));
msg->headerField("X-Status").latin1());
if ( msg->headerField( "X-KMail-EncryptionState" ).size() )
msg->setEncryptionStateChar( msg->headerField( "X-KMail-EncryptionState" ).at(0) );
if ( msg->headerField( "X-KMail-SignatureState" ).size() )
msg->setSignatureStateChar( msg->headerField( "X-KMail-SignatureState" ).at(0));
addedOk = processNewMsg(msg);
if (addedOk)

@ -405,9 +405,12 @@ void KMMessage::fromDwString(const DwString& str, bool aSetStatus)
if (aSetStatus) {
setStatus(headerField("Status").latin1(), headerField("X-Status").latin1());
setEncryptionStateChar( headerField("X-KMail-EncryptionState").at(0) );
setSignatureStateChar( headerField("X-KMail-SignatureState").at(0) );
setMDNSentState( static_cast<KMMsgMDNSentState>( headerField("X-KMail-MDN-Sent").at(0).latin1() ) );
if ( headerField( "X-KMail-EncryptionState" ).size() )
setEncryptionStateChar( headerField( "X-KMail-EncryptionState" ).at(0) );
if ( headerField( "X-KMail-SignatureState" ).size() )
setSignatureStateChar( headerField( "X-KMail-SignatureState" ).at(0));
if ( headerField("X-KMail-MDN-Sent").size() )
setMDNSentState( static_cast<KMMsgMDNSentState>( headerField("X-KMail-MDN-Sent").at(0).latin1() ) );
}
if (attachmentState() == KMMsgAttachmentUnknown && readyToShow())
updateAttachmentState();

Loading…
Cancel
Save