Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-type header inside the actual content is not mandatory #28

Open
psoares-resilient opened this issue May 6, 2020 · 1 comment

Comments

@psoares-resilient
Copy link

Hi,

Sending a multipart that contains no Content-Type header inside breaks the parsing... Content-Type is used after the filename for matches, however it is not to be assumed there. Taken from the RFC1341

"A body part is NOT to be interpreted as actually being an RFC 822 message. To begin with, NO header fields are actually required in body parts. (...) the absence of a Content-Type header field implies that the encapsulation is plain US-ASCII text."

https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html

We want to use this lib but we will have to use a fork instead and raise a PR if this is still being maintained?

@spidgorny
Copy link

Quick and dirty fix

      body = multipart.parse(event);
      if ("pdf" in body && body.pdf.content.includes("\r\n\r\n")) {
        // https://github.com/myshenin/aws-lambda-multipart-parser/issues/28
        body.pdf.content = body.pdf.content.split("\r\n\r\n")[1];
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants