Parcel:MIME - Net.MessageParser>>parseBody: body from: rfc822Scanner - BUG?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Parcel:MIME - Net.MessageParser>>parseBody: body from: rfc822Scanner - BUG?

Stew MacLean

I believe that the line in the MessageParser>>pareseBody:from

 

rfc822Scanner peekFor: Character lf.

 

is in error. This only becomes aparent when the first character(s) of the body is(are) a LF(s). In this case the peek actually succeeds in finding and advancing the position of the stream, thus causing the LF to be dropped.

 

As the stream is actually positioned at the trailing header LF, no peek needs to be done, as the next “next” will correctly answer the first character of the body.

 

MessageParser>>pareseBody:from

 

            | outStream  |

 

            (self action: #startBody: with: body)

                        ifTrue:

                                    [rfc822Scanner source isInternal

                                                ifTrue:

                                                            [outStream := rfc822Scanner source upToEnd asByteArrayEncoding: self encoder.

                                                rfc822Scanner source:  (outStream withEncoding: self encoder ) readStream.

                                                            rfc822Scanner source lineEndCR ].

                                    "After parsing header fields the current position is looking at LF, skip it"

                                    "rfc822Scanner peekFor: Character lf. "

                                    body isSimple

                                                ifTrue: [self parseSimpleBody: body from: rfc822Scanner]

                                                ifFalse: [self parseMultipartBody: body from: rfc822Scanner].

                                    self action: #endBody: with: body].

            ^body

 

I would appreciate it if someone would substantiate this.

 

Cheers,

 

Stewart

 

 

PS A belated Happy New Year to the list…