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

Gracefully handle non-conforming Content-Disposition headers #5988

Open
1 task done
tilsche opened this issue Sep 7, 2021 · 1 comment
Open
1 task done

Gracefully handle non-conforming Content-Disposition headers #5988

tilsche opened this issue Sep 7, 2021 · 1 comment

Comments

@tilsche
Copy link

tilsche commented Sep 7, 2021

Is your feature request related to a problem?

I have encountered servers that send content disposition headers with extra semicolons at the end, e.g.

Content-Disposition: inline; filename="foo.obj";

I understand this is technically non-conforming, but it still contains useful and easily correctly parsable information.

Describe the solution you'd like

aiohttp should gracefully handle minor non-conformance and include the content_disposition with values. It can still emit a warning.

Describe alternatives you've considered

Fixing this in all broken servers is highly unlikely.

Related component

Client

Additional context

Both chromium and wget --content-disposition treat these cases gracefully.

It is a small change to continue here:

return None, {}

Alternative solutions with increasing strictness would be to

  1. discard empty parts
  2. discard whitespace-only parts
  3. discard semicolons at the very end of the header

I'm happy to create a PR with the preferred solution.

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@asvetlov
Copy link
Member

I think option 2 covers most cases.
Pull Request is welcome!

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

No branches or pull requests

3 participants