Message: decoding of quoted-printable RFC1522 strings

was broken for strings that started with a decoded character.

svn path=/trunk/kdenetwork/kmail/; revision=6280
wilder-work
Stefan Taferner 28 years ago
parent 3d2b75f877
commit b7d94ec5e9
  1. 7
      ChangeLog
  2. 51
      kmmsgbase.cpp
  3. 2
      kmversion.h

@ -1,4 +1,9 @@
1998-03-18 Stefan Taferner <taferner@kde.org> (KMail-0.6.4)
1998-03-24 Stefan Taferner <taferner@kde.org> (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 <taferner@kde.org>
* Reader: improved detection of urls and email addresses
to ignore special characters at the end, e.g. "." or ")".

@ -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<end && (*pos!='?' && (ispunct(*pos) || isalnum(*pos))))
pos++;
if (*pos != '?' || (end-pos) < 4) valid = FALSE;
else
mid = pos;
// search for end of encoded part
while (i<76 && *pos && !(*pos=='?' && *(pos+1)=='='))
{
// get encoding and check delimiting question marks
i++;
pos++;
encoding = toupper(*pos++);
if (*pos++ != '?' || (encoding!='Q' && encoding!='B'))
valid = FALSE;
}
end = pos+2;//end now points to the first char after the encoded string
if (i>=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';

@ -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*/

Loading…
Cancel
Save