[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: [PATCH] adhere a bit more to RFC2047 in decodeRFC2047String() (was:
From: Marc Mutz <Marc.Mutz () uni-bielefeld ! de>
Date: 2001-07-01 0:24:44
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sunday 01 July 2001 01:31, Marc Mutz wrote:
<snip>
> Then the right fix is to shove the unfolding up to the beginning of
> the function. I guess the current code eleminates spaces between
> adjacent RFC2047-encoded blocks? They are also to be ignored.
> (Hmm, doesn't seem so...)
<snip>
I've made something up, but:
- - Does decodeRFC2047String() need to be able to work with CRLF'ed input?
- - Why are spaces in the charset-identifier allowed? RFC2047 clearly
states that any encoded-word MUST NOT contain white space...?
Patch attached. Seems to work. At least it shows your names right,
Michael and Ingo.
Unfortunately I was too fast in deleting the Bruno's testmail.
Index: kmmsgbase.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmmsgbase.cpp,v
retrieving revision 1.80
diff -u -3 -p -r1.80 kmmsgbase.cpp
- --- kmmsgbase.cpp 2001/06/30 19:55:07 1.80
+++ kmmsgbase.cpp 2001/07/01 00:21:54
@@ -208,7 +208,7 @@ QString KMMsgBase::decodeRFC2047String(c
char *pos, *beg, *end, *mid;
QCString str, cstr;
char encoding, ch;
- - bool valid;
+ bool valid, lastWasEncodedWord=FALSE;
const int maxLen=200;
int i;
@@ -216,11 +216,18 @@ QString KMMsgBase::decodeRFC2047String(c
for (pos=aStr.data(); *pos; pos++)
{
+ // unfold and ignore LWS between adjacent encoded-word's
+ if ( pos[0] == '\n' ||
+ ( lastWasEncodedWord && ( pos[0] == ' ' || pos[0] == '\t' ) ) )
+ continue;
+ lastWasEncodedWord = FALSE;
+ // verbatimly copy normal text
if (pos[0]!='=' || pos[1]!='?')
{
result += *pos;
continue;
}
+ // found possible encoded-word
beg = pos+2;
end = beg;
valid = TRUE;
@@ -270,6 +277,7 @@ QString KMMsgBase::decodeRFC2047String(c
// decode base64 text
cstr = decodeBase64(str);
}
+ lastWasEncodedWord = TRUE;
QTextCodec *codec = codecForName(charset);
if (!codec) codec =
codecForName(KGlobal::locale()->charset().latin1());
if (codec) result += codec->toUnicode(cstr);
@@ -287,7 +295,7 @@ QString KMMsgBase::decodeRFC2047String(c
result += *pos;
}
}
- - return result.replace(QRegExp("\n[ \t]")," ");
+ return result;
}
Marc
- --
Marc Mutz <Marc@Mutz.com>
http://marc.mutz.com/
http://www.mathematik.uni-bielefeld.de/~mmutz/
http://EncryptionHOWTO.sourceforge.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE7Pm3X3oWD+L2/6DgRAo3TAKDsrWZ2jiU7z4QPZOiB31uhG6BZwQCgmwv+
HTzx9G9N6O91TJrjf4ez7Yg=
=hkPF
-----END PGP SIGNATURE-----
_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic