Show quoted text> You still have to remove the first white space which is mandated to be
> inserted.
This is still *WRONG*. READ THE RFC!
http://www.faqs.org/rfcs/rfc2822.html
Show quoted text> Unfolding is accomplished by simply removing any CRLF
> that is immediately followed by WSP
The bug here is that you're folding lines incorrectly, because you
should only be folding at FWS. Again, READ THE RFC!
http://www.faqs.org/rfcs/rfc2822.html
Show quoted text> The general rule is
> that wherever this standard allows for folding white space (not
> simply WSP characters), a CRLF may be inserted before any WSP.
You said:
Show quoted text> Otherwise t/mime-header.t fails.
This is because your folding encoding + folding routines are wrong.
perl -e 'use Encode; print encode("MIME-Q", "Subject: \x{f3}");'
Outputs:
Subject:=?UTF-8?Q?=20=C3=B3?=
You're encoding the space character into the encoded value, you should
be doing:
Subject: =?UTF-8?Q?=C3=B3?=
So that for a long line, you can fold that into:
Subject:
=?UTF-8?Q?=C3=B3?=
And have it unfold correctly.
So the real problem is that the encoding is swallowing the FWS into the
encoded-words, which then means you folding can't fold properly because
there is no FWS left to fold on.
Ick, just checking the code, it's inserting arbitrary "\n " lines
itself, rather than actually folding at FWS points. That's just
completely bogus.
Basically it seems to me that the encode() function is broken, for two
reasons:
1. It's absorbing all whitespace into the encoded-word, thus leaving no
points for FWS to fold on
2. It's arbitrarily folding at any point and inserting "\n " at the fold
point, rather than trying to find FWS and folding there.
Referring back to RFC2822 again.
Show quoted text> The general rule is
> that wherever this standard allows for folding white space (not
> simply WSP characters), a CRLF may be inserted before any WSP.
So you can't just aribitrarily inserts a "\n " in your text, you have to
insert a "\n" only before a FWS point so the unfolding works correctly.
Rob