You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by "Ken--@newsgroupstats.hk" <dr...@gmail.com> on 2010/08/01 14:19:37 UTC

quoteprintable message distorted

Hi All,

I am trying to switch from javamail to mime4j. I got some problem when
parsing quoteprintable message with MIME4J like this:

http://put.hk/source/news.twonil.com.hk/general.chat/1771446.html

it's an usenet message.

I got many warnings during new Message(inputstream, mimeconfig):

W/tedPrintableInputStream(  918): Malformed MIME; expected \r or [0-9A-Z],
got 10

It seems that there has no workaround unless adding '\r' for every new line.

Please advise.

Regards,
Ken


-- 
View this message in context: http://old.nabble.com/quoteprintable-message-distorted-tp29317840p29317840.html
Sent from the James - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: quoteprintable message distorted

Posted by "Ken--@newsgroupstats.hk" <dr...@gmail.com>.

Actually, many local nntp servers (Hong Kong) contain non-ascii messages as
well and didn't well quote RFC 2047 in header and even have no Content-Type
defined (because some bad nntp clients like Outlook express and Outlook
express provide a default charset option for reading message -_-!).

e.g. http://put.hk/source/news.3home.net/test/13769.html

With mime4j, these kind of messages cannot be well parsed as Message entity
provide no way to pass a default charset if the message didn't mention the
charset. MIME4j's Message, by default will use US-ASCII to parse message and
will have distorted result.

Someone has hacked into MIME4j before to workaround this problem:

http://sourceforge.net/projects/android-usenet/files/source-release/usenet.git.tar.bz2/download

Thanks to your attention.

Regards,
Ken
-- 
View this message in context: http://old.nabble.com/quoteprintable-message-distorted-tp29317840p29327569.html
Sent from the James - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: quoteprintable message distorted

Posted by "Ken--@newsgroupstats.hk" <dr...@gmail.com>.
Message message;

public void parseMessage(InputStream inputStream) {
	StorageProvider storageProvider = new MemoryStorageProvider();
	DefaultStorageProvider.setInstance(storageProvider);
	MimeEntityConfig mimeConfig = new MimeEntityConfig();
	mimeConfig.setMaxLineLen(-1);
	mimeConfig.setStrictParsing(false);
	try {
		message = new Message(inputStream, mimeConfig);
	} catch (Exception e) {
	}
}

It's not work either. Same warning messages come out.

So, I hacked into mime4j, everything goes well then:

org.apache.james.mime4j.codec.QuotedPrintableInputStream:

                case 1:  // encountered "=" so far
                    if (b == '\r') {
                        state = 2;
                        break;
// added by Ken for fixing missing '\r' problem inside quoteprintable
message
                    } else if (b == '\n') {
                    	state = 0;
                    	break;
// end
                    } else if ((b >= '0' && b <= '9') || (b >= 'A' && b <=
'F') || (b >= 'a' && b <= 'f')) {
                        state = 3;
                        msdChar = b;  // save until next digit encountered
                        break;
                    } 







Norman Maurer-3 wrote:
> 
> Hi Ken,
> 
> can you show me the Code you use ? Do you disable strict parsing ?
> 
> http://james.apache.org/mime4j/apidocs/org/apache/james/mime4j/parser/MimeEntityConfig.html
> 
> Bye,
> Norman
> 
> 
-- 
View this message in context: http://old.nabble.com/quoteprintable-message-distorted-tp29317840p29327556.html
Sent from the James - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: quoteprintable message distorted

Posted by Norman Maurer <no...@apache.org>.
Hi Ken,

can you show me the Code you use ? Do you disable strict parsing ?

http://james.apache.org/mime4j/apidocs/org/apache/james/mime4j/parser/MimeEntityConfig.html

Bye,
Norman

2010/8/1 Ken--@newsgroupstats.hk <dr...@gmail.com>:
>
>> so the lines are only terminated by a "\n" and not by "\r\n" ?
>
> Yes
>
> --
> View this message in context: http://old.nabble.com/quoteprintable-message-distorted-tp29317840p29318764.html
> Sent from the James - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: quoteprintable message distorted

Posted by "Ken--@newsgroupstats.hk" <dr...@gmail.com>.
> so the lines are only terminated by a "\n" and not by "\r\n" ?

Yes

-- 
View this message in context: http://old.nabble.com/quoteprintable-message-distorted-tp29317840p29318764.html
Sent from the James - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: quoteprintable message distorted

Posted by "Ken--@newsgroupstats.hk" <dr...@gmail.com>.
"\n"

in nntp world, many messages are not 100% fully compliance.

Regards,
Ken



Norman Maurer-3 wrote:
> 
> Hi Ken,
> 
> so the lines are only terminated by a "\n" and not by "\r\n" ?
> 
> Bye,
> Norman
> 
> 
> 2010/8/1 Ken--@newsgroupstats.hk <dr...@gmail.com>:
>>
>> Hi All,
>>
>> I am trying to switch from javamail to mime4j. I got some problem when
>> parsing quoteprintable message with MIME4J like this:
>>
>> http://put.hk/source/news.twonil.com.hk/general.chat/1771446.html
>>
>> it's an usenet message.
>>
>> I got many warnings during new Message(inputstream, mimeconfig):
>>
>> W/tedPrintableInputStream(  918): Malformed MIME; expected \r or
>> [0-9A-Z],
>> got 10
>>
>> It seems that there has no workaround unless adding '\r' for every new
>> line.
>>
>> Please advise.
>>
>> Regards,
>> Ken
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/quoteprintable-message-distorted-tp29317840p29317840.html
>> Sent from the James - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-user-help@james.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/quoteprintable-message-distorted-tp29317840p29318759.html
Sent from the James - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: quoteprintable message distorted

Posted by Norman Maurer <no...@apache.org>.
Hi Ken,

so the lines are only terminated by a "\n" and not by "\r\n" ?

Bye,
Norman


2010/8/1 Ken--@newsgroupstats.hk <dr...@gmail.com>:
>
> Hi All,
>
> I am trying to switch from javamail to mime4j. I got some problem when
> parsing quoteprintable message with MIME4J like this:
>
> http://put.hk/source/news.twonil.com.hk/general.chat/1771446.html
>
> it's an usenet message.
>
> I got many warnings during new Message(inputstream, mimeconfig):
>
> W/tedPrintableInputStream(  918): Malformed MIME; expected \r or [0-9A-Z],
> got 10
>
> It seems that there has no workaround unless adding '\r' for every new line.
>
> Please advise.
>
> Regards,
> Ken
>
>
> --
> View this message in context: http://old.nabble.com/quoteprintable-message-distorted-tp29317840p29317840.html
> Sent from the James - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org