Mantis - Squeak
Viewing Issue Advanced Details
1131 Network minor always 04-28-05 18:55 02-16-11 00:38
murphydye  
KenCausey  
normal  
closed 3.8  
fixed  
none    
none 4.1  
0001131: Linefeeds in mail message
When fetching email messages from an IMAP server, the lines end with cr/lf. MailMessage>>from: expects only cr and parses these messages incorrectly. Peeking for lf in #readStringLineFrom: fixes this:

MailMessage>>readStringLineFrom: aStream
    "Read and answer the next line from the given stream. Consume the carriage return but do not append it to the string."
    | line |
    line := aStream upTo: Character cr.
    aStream peek = Character lf ifTrue: [aStream next].
    ^ line

Notes
(0002935)
murphydye   
10-20-05 22:24   
I had problems with my initial solution under certain conditions, and chose to strip all linefeeds in the MailMessage>>from: method. I did this right after the 'text' variable is set. It seems like I also added them back in when writing the message, for example when writing the headers out, but don't see where I did this. Note, this solution is not ideal ;)

MailMessage>>from: aString
    "Parse aString to initialize myself."

    | parseStream contentType bodyText contentTransferEncoding |

    text := aString withoutTrailingBlanks, String cr.
"bmd added this to get rid of lf problems"
    text := text copyWithout: Character lf.
    parseStream := ReadStream on: text.
...

(0014052)
nicolas cellier   
02-16-11 00:38   
This was solved in Squeak 4.1 by using generic Stream utility nextLine