dotnet-websharper / owin

Wrappers for hosting WebSharper sitelets and remoting components in OWIN projects
Apache License 2.0
10 stars 9 forks source link

Filepart with endboundary just at the end of the buffer #22

Open GiovanniDeGroote opened 6 years ago

GiovanniDeGroote commented 6 years ago

When you have a file part with the correct length, placing the endboundary just at the end of a buffer leaving out the "--" it will be seen as a simple boundary giving exceptions in the next section. I changed the code to:

else if (boundaryPos >= 0 && endBoundaryPos < 0)
                {
                    // if the boundary is at the and of the buffer, it can be a potential endboundry where the "--" was just missed 
                    // if so, don't mark it as an end, so another buffer will be read
                    if (boundaryPos + boundaryLength < (this.BinaryBufferSize * 2) - 2)
                    {
                        // Select boundary    
                        endPos = boundaryPos;
                        endPosLength = boundaryLength;
                    }
                }
Tarmil commented 6 years ago

That's a good catch. Do you want to submit a PR for this fix? Or I can make the change.

GiovanniDeGroote commented 6 years ago

You may make the change :)