From b7d94ec5e9640836343ee7b5b1b13bc258850c17 Mon Sep 17 00:00:00 2001 From: Stefan Taferner Date: Tue, 24 Mar 1998 20:37:30 +0000 Subject: [PATCH] Message: decoding of quoted-printable RFC1522 strings was broken for strings that started with a decoded character. svn path=/trunk/kdenetwork/kmail/; revision=6280 --- ChangeLog | 7 ++++++- kmmsgbase.cpp | 51 +++++++++++++++++++++++++++------------------------ kmversion.h | 2 +- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5eedcbba0..ab98d0d8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -1998-03-18 Stefan Taferner (KMail-0.6.4) +1998-03-24 Stefan Taferner (KMail-0.6.4) + + * Message: decoding of quoted-printable RFC1522 strings + was broken for strings that started with a decoded character. + +1998-03-18 Stefan Taferner * Reader: improved detection of urls and email addresses to ignore special characters at the end, e.g. "." or ")". diff --git a/kmmsgbase.cpp b/kmmsgbase.cpp index 6cc68e249..4b8e23bac 100644 --- a/kmmsgbase.cpp +++ b/kmmsgbase.cpp @@ -289,9 +289,9 @@ const QString KMMsgBase::decodeRFC1522String(const QString aStr) { #ifndef BROKEN static QString result; - char *pos, *dest, *beg, *end; + char *pos, *dest, *beg, *end, *mid; QString str; - char encoding; + char encoding, ch; bool valid; int i; @@ -304,39 +304,41 @@ const QString KMMsgBase::decodeRFC1522String(const QString aStr) continue; } beg = pos+2; - // search for end of encoded part - for (i=2, end=beg, valid=FALSE; *end && i<76; end++, i++) + end = beg; + valid = TRUE; + // parse charset name + for (i=2,pos+=2; i<76 && (*pos!='?'&&(ispunct(*pos)||isalnum(*pos))); i++) + pos++; + if (*pos!='?' || i<4 || i>=76) valid = FALSE; + else { - if (end[0]=='?' && end[1]=='=') - { - valid = TRUE; - break; - } + // get encoding and check delimiting question marks + encoding = toupper(pos[1]); + if (pos[2]!='?' || (encoding!='Q' && encoding!='B')) + valid = FALSE; + pos+=3; + i+=3; } if (valid) { - end += 2; // end now points to the first char after the encoded string - pos = beg; - // parse charset name - while (pos=76 || !*pos) valid = FALSE; } if (valid) { - str = QString(pos, (int)(end - pos - 1)); + ch = *pos; + *pos = '\0'; + str = QString(mid, (int)(mid - pos - 1)); if (encoding == 'Q') { // decode quoted printable text - str.detach(); for (i=str.length()-1; i>=0; i--) if (str[i]=='_') str[i]=' '; str = decodeQuotedPrintable(str); @@ -346,15 +348,16 @@ const QString KMMsgBase::decodeRFC1522String(const QString aStr) // decode base64 text str = decodeBase64(str); } + *pos = ch; for (i=0; str[i]; i++) *dest++ = str[i]; - pos = end - 1; + pos = end -1; } else { result += "=?"; - pos = beg - 1; + pos = beg -1; // because pos gets increased shortly afterwards } } *dest = '\0'; diff --git a/kmversion.h b/kmversion.h index 42c28d584..51dfa0254 100644 --- a/kmversion.h +++ b/kmversion.h @@ -3,6 +3,6 @@ #ifndef kmversion_h #define kmversion_h -#define KMAIL_VERSION "0.6.3" +#define KMAIL_VERSION "0.6.4" #endif /*kmversion_h*/