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

Allow filename content disposition to have space in accordance with RFC6266 Appendix D #6826

Conversation

ben-cutler-datarobot
Copy link

@ben-cutler-datarobot ben-cutler-datarobot commented Jul 14, 2022

What do these changes do?

According to RFC 6266 Appendix D:
https://datatracker.ietf.org/doc/html/rfc6266#appendix-D

   o  Avoid including the percent character followed by two hexadecimal
      characters (e.g., %A9) in the filename parameter, since some
      existing implementations consider it to be an escape character,
      while others will pass it through unchanged.

The current implementation of aiohttp does encode spaces of the filename, and this implementation should be avoided,.

Are there changes in behavior for the user?

Yes, filenames will no longer be encoded.

This is not exactly a new change for users on aiohttp 3.7 though. The filename was not encoded until this Pr #4012 encoded it.

Related issue number

Checklist

  • [✅] I think the code is well written
  • [✅] Unit tests for the changes exist
  • [⚠️] Documentation reflects the changes
  • [✅] If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • [✅] Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Jul 14, 2022
@ben-cutler-datarobot
Copy link
Author

I realized there's a better solution. I realized the FormData has a constructor param (quote_fields=False) that I should be using instead

@madduck
Copy link

madduck commented May 26, 2024

I realized there's a better solution. I realized the FormData has a constructor param (quote_fields=False) that I should be using instead

Doesn't this potentially have side-effects we don't want? After all, fields should be quoted in general, no? Just the filename should not be quoted…

madduck added a commit to madduck/paperless-api that referenced this pull request May 26, 2024
The `aiohttp.FormData` default is to encode all parameter data on form
fields, and this causes e.g. spaces to be converted to `%20`, which are
then [exposed in the Paperless-NGX
UI](paperless-ngx/paperless-ngx#6830).

I interpret the [`aiohttp`
issue](aio-libs/aiohttp#6826) to mean that the
filename should *not* be percent-encoded, and the [proposed
solution](aio-libs/aiohttp#6826 (comment))
is to set `quote_fields=False` in the constructor of `aiohttp.FormData`.

Which is what this PR does.

Signed-off-by: martin f. krafft <[email protected]>
tb1337 pushed a commit to tb1337/paperless-api that referenced this pull request May 27, 2024
The `aiohttp.FormData` default is to encode all parameter data on form
fields, and this causes e.g. spaces to be converted to `%20`, which are
then [exposed in the Paperless-NGX
UI](paperless-ngx/paperless-ngx#6830).

I interpret the [`aiohttp`
issue](aio-libs/aiohttp#6826) to mean that the
filename should *not* be percent-encoded, and the [proposed
solution](aio-libs/aiohttp#6826 (comment))
is to set `quote_fields=False` in the constructor of `aiohttp.FormData`.

Which is what this PR does.

Signed-off-by: martin f. krafft <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants