• mpl's avatar
    mime/multipart: fix peekBufferSeparatorIndex edge case · 821b5492
    mpl authored
    The case fixed by this change happens when, in func (pr partReader)
    Read, the Peek happens to read so that peek looks like:
    
      "somedata\r\n--Boundary\r"
    
    peekBufferSeparatorIndex was returning (-1, false) because it didn't
    find the trailing '\n'.
    
    This was wrong because:
    
    1) It didn't match the documentation: as "\r\n--Boundary" was found, it
    should return the index of that pattern, not -1.
    
    2) It lead to an nCopy cut such as:
      "somedata\r| |\n--Boundary\r" instead of "somedata| |\r\n--Boundary\r"
    which made the subsequent Read miss the boundary, and eventually end
    with a "return 0, io.ErrUnexpectedEOF" case, as reported in:
    
    https://github.com/camlistore/camlistore/issues/642
    
    Change-Id: I1ba78a741bc0c7719e160add9cca932d10f8a615
    Reviewed-on: https://go-review.googlesource.com/15269Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    821b5492
Name
Last commit
Last update
..
testdata Loading commit data...
example_test.go Loading commit data...
formdata.go Loading commit data...
formdata_test.go Loading commit data...
multipart.go Loading commit data...
multipart_test.go Loading commit data...
writer.go Loading commit data...
writer_test.go Loading commit data...