danabr / multipart-parser

A multipart parser written in Ruby
MIT License
17 stars 10 forks source link

fix LongBoundary test #5

Closed arton closed 6 years ago

arton commented 6 years ago

Hi danabr,

Thank you for the gem. I found that the fixture of LongBoundary test was not correct, because the raw data lacks '--'. I also fixed the require path for parser_test as it can work as reader_test. I tried to use multipart-parser with Ruby 2.3.1 and it runs fine.

Cheers

danabr commented 6 years ago

Thank you. It was years ago I last worked with this, so I cannot really do a proper review, i.e. tell if the change makes sense. How did you find out that the test is incorrect?

arton commented 6 years ago

Hi danabar

My PR solves the test failure, cause the count of '-' mismatch.

Original fixture defines its boundary as '----------------------------5c4dc587f69f'. The count of '-' is 28. Parser adds extra '--' to given boundary. '--' (2 of '-') is defined by the specification. The problems are in your fixture data.

 def raw
      ['----------------------------5c4dc587f69f',
        'content-disposition: form-data; name="field1"',
        '',
        "Joe Blow\r\nalmost tricked you!",
        '----------------------------5c4dc587f69f--'
      ].join("\r\n")
    end

It uses '----------------------------5c4dc587f69f' and '----------------------------5c4dc587f69f--'. Both of the partitions have 28 '-' front of '5c4dc...'. Parser compares the given and modified boundary with 30 '-' against 28 '-' partition data, then it fails the comparison because number of '-' are different.

My PR fixed the number of '-' for raw data with 30 '-'.

Regards