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

Extraneous whitespace in Content-Disposition filename parameter causes parse error #1386

Open
HermanHiddema opened this issue Mar 25, 2020 · 1 comment · May be fixed by #1592
Open

Extraneous whitespace in Content-Disposition filename parameter causes parse error #1386

HermanHiddema opened this issue Mar 25, 2020 · 1 comment · May be fixed by #1592

Comments

@HermanHiddema
Copy link

HermanHiddema commented Mar 25, 2020

I sporadically had trouble extracting attachments from some received mails, which when checked do work in GMail. After analysis, I traced it down to extraneous whitespace in the Content-Disposition header of the attachment part.

Specifically, the following headers:

--boundarystring
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename = "file.pdf"

[base64 data]

fail with the follow parse error:

#<Mail::Field::IncompleteParseError: Mail::ContentDispositionElement can not parse |attachment; filename = "file.pdf"|: Only able to parse up to "attachment; filename">

removing the extraneous whitespace around the = character:

--boundarystring
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="file.pdf"

[base64 data]

works as expected.

Both cases work as expected in GMail.

I've checked RFC 2183 and RFC 822, and it is not entirely clear to me whether this white-space is legal (RFC 822 section 3.1.4 does say "free insertion of linear-white-space (which permits folding by inclusion of CRLFs) is allowed between lexical tokens." but I do not know if that applies here).

Regardless of standards conformance, there is probably no downside to being slightly more lenient here and allow the spaces.

Probably somewhat related: #200

@pshutt
Copy link

pshutt commented Jul 1, 2021

I am having the same issue

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

Successfully merging a pull request may close this issue.

2 participants