[Mono-dev] StreamReader ReadLine Issue

Mike Glenn mglenn at zoominternet.net
Fri Feb 10 16:55:01 EST 2006


Hello all,

I've run into an issue with StreamReader.ReadLine() and differences in MS.Net
implementation. Here's the basics of it:

While reading messages from a pop server I encountered a message that had some
improper formatting that looked like this (using escapes to show the data stream
as it was past to me):

From: someone at somewhere.com\r\n
Subject: Something that you don't care about\r\r\n
X-SomeHeader: blah blah blah\r\n
\r\n
some message body\r
some more\r\n
\r\n
.\r\n

If you note on the subject line there are 2 \r's mono returns the subject line
and on the next call returns an empty line. MS returns the subject line and on
the following call returns the X-Header line. This behavior causes my code to
see the end of the headers and the beginning of the body as rfc822 specs out.
This of course is wrong and things really go down hill when I see the body line
with only the \r.

The attached patch, against mcs, changes how StreamReader.FindNextEOL()
functions to deal with things correctly for me. I'm not sure that it's the best
way or even the correct way to solve this, but I hope it at least gives enough
info to create a unit test for this kind of thing and deal with it properly.

Mike Glenn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: StreamReader_EOL.patch
Type: application/octet-stream
Size: 1452 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060210/83bd960f/attachment.obj 


More information about the Mono-devel-list mailing list