Steen,

How's this work for you?

    public void write(int b) throws IOException {
        switch (b) {
            case '.':
                if (countLast0A0D == 2) {
                    out.write('.');
                }
                countLast0A0D = 0;
                break;
            case '\r':
                countLast0A0D = 1;
                break;
            case '\n':
                if (countLast0A0D == 1) {
                    countLast0A0D = 2;
                } else {
                    out.write('\r');
                    countLast0A0D = 0;
                }
                break;
            default:
                countLast0A0D = 0;
                break;
        }
        out.write(b);
    }

The problem that I have with it now is that although it converts a naked LF
to CRLF, it won't double the '.' after a line that improperly begins with
just LF.

        --- Noel

-----Original Message-----
From: Steen Jansdal [mailto:[EMAIL PROTECTED]
Sent: Monday, March 10, 2003 4:08
To: James Users List
Subject: Re: Missing Carriage Return


Steen Jansdal wrote:
> Steen Jansdal wrote:
>
>> Hi,
>>
>> This has possibly been asked before, but I cannot
>> find it in the mail archieve.
>>
>> It seems as there are missing some Carriage Returns
>> after some of the lines in a mail. My Outlook users
>> are getting strange looking mails.
>>
>> Is this a configuration options that I simply hasn't
>> found?
>>
>> Steen
>>
>
> Now I've found out that this occurs when HTML-mails or mails
> with attachments are fetchPOP'ed. Each line in a mail should
> be terminated with a CR LF (according to RFC2821), but in
> some cases these are only terminated by a LF.
>
> The mail-server (James 2.1.2) is running on a Linux platform.
>
> Steen
>
>

Now I have a patch that fixes the problem. I don't know
if it's the right place to fix the problem, but it works.

In the ExtraDotOutputStream class (package org.apache.james.util)
the method "write" are patched as follows:

     public void write(int b) throws IOException {
//        out.write(b);                   // Remove this line

         switch (b) {
             case '.':
                 out.write(b);             // Add this line
                 if (countLast0A0D == 2) {
                     // add extra dot
                     out.write('.');
                 }
                 countLast0A0D = 0;
                 break;
             case '\r':
                 out.write(b);             // Add this line
                 countLast0A0D = 1;
                 break;
             case '\n':
                 if (countLast0A0D == 1) {
                     out.write(b);         // Add this line
                     countLast0A0D = 2;
                 } else {
                     out.write('\r');      // Add this line

                     out.write(b);
                     countLast0A0D = 0;
                 }
                 break;
             default:
                 out.write(b);             // Add this line
                 // we're  no longer at the start of a line
                 countLast0A0D = 0;
                 break;
         }
     }


Steen


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to